Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically restore & run the app from Visual Studio #5

Merged
merged 3 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class PortsOfEntryController : ControllerBase
private readonly DataContext dataContext;
private readonly IConfiguration configuration;
public PortsOfEntryController (DataContext dataContext, IConfiguration configuration) {
dataContext.Database.EnsureCreated();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇 oooo!

this.configuration = configuration;
this.dataContext = dataContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class RepresentativeDataController : ControllerBase {
private readonly DataContext dataContext;
private readonly IConfiguration configuration;
public RepresentativeDataController (DataContext dataContext, IConfiguration configuration) {
dataContext.Database.EnsureCreated();
this.configuration = configuration;
this.dataContext = dataContext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class ScreeningDataTableController : ControllerBase {
private readonly IConfiguration configuration;
private readonly DataContext dataContext;
public ScreeningDataTableController (DataContext dataContext, IConfiguration configuration) {
dataContext.Database.EnsureCreated();
this.dataContext = dataContext;
this.configuration = configuration;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious what's the purpose of the arm template if we already have the cli script? not a complaint, just curious.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VS automatically picks up the arm template on restore and creates all required resources as needed.

"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "covidscreeningrg",
"metadata": {
"_parameterType": "resourceGroup",
"description": "Name of the resource group for the resource. It is recommended to put resources under same resource group for better tracking."
}
},
"resourceGroupLocation": {
"type": "string",
"defaultValue": "West US",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource group. Resource groups could have different location than resources."
}
},
"resourceLocation": {
"type": "string",
"defaultValue": "[parameters('resourceGroupLocation')]",
"metadata": {
"_parameterType": "location",
"description": "Location of the resource. By default use resource group's location, unless the resource provider is not supported there."
}
}
},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"name": "[parameters('resourceGroupName')]",
"location": "[parameters('resourceGroupLocation')]",
"apiVersion": "2019-10-01"
},
{
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('resourceGroupName'), 'Deployment', uniqueString(concat('covid-screening-api', subscription().subscriptionId)))]",
"resourceGroup": "[parameters('resourceGroupName')]",
"apiVersion": "2019-10-01",
"dependsOn": [
"[parameters('resourceGroupName')]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"name": "covid-screening-api",
"location": "[parameters('resourceLocation')]",
"type": "Microsoft.DocumentDB/databaseAccounts",
"kind": "GlobalDocumentDB",
"properties": {
"databaseAccountOfferType": "Standard"
},
"apiVersion": "2015-04-08"
}
]
}
}
}
],
"metadata": {
"_dependencyType": "cosmosdb.azure"
}
}
3 changes: 3 additions & 0 deletions src/COVIDScreeningApi/Properties/serviceDependencies.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"dependencies": {
"secrets1": {
"type": "secrets"
},
"cosmosdb1": {
"type": "cosmosdb",
"connectionId": "CosmosDbConnectionString"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{
"dependencies": {
"secrets1": {
"type": "secrets.user"
},
"cosmosdb1": {
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroup')]/providers/Microsoft.DocumentDB/databaseAccounts/covid-screening-data",
"resourceId": "/subscriptions/[parameters('subscriptionId')]/resourceGroups/[parameters('resourceGroupName')]/providers/Microsoft.DocumentDB/databaseAccounts/covid-screening-api",
"type": "cosmosdb.azure",
"connectionId": "CosmosDbConnectionString",
"secretStore": "LocalSecretsFile"
Expand Down