Skip to content

Commit

Permalink
Support for automatic db migration & restore
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayrkn committed Jun 25, 2020
1 parent 744127e commit 2755fb7
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 1 deletion.
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();
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 @@
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupName": {
"type": "string",
"defaultValue": "covidScreeningApi",
"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": "westcentralus",
"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('covidScreeningApi', 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": "covidScreeningApi",
"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/covidScreeningApi",
"type": "cosmosdb.azure",
"connectionId": "CosmosDbConnectionString",
"secretStore": "LocalSecretsFile"
Expand Down

0 comments on commit 2755fb7

Please sign in to comment.