Skip to content

Commit

Permalink
Add PostgreSQL database to deployment (#1112)
Browse files Browse the repository at this point in the history
* Add PostgreSQL database to deployment

* Add ARM lint task to v3-dev branch

* Add github actions to solution file
  • Loading branch information
kbeaugrand committed Sep 4, 2022
1 parent e883086 commit 57207ba
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/arm-ttk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Validate ARM templates

on:
pull_request:
branches: [ main ]
branches: [ main, v3-dev ]
paths:
- 'templates/**'
push:
Expand Down
2 changes: 2 additions & 0 deletions src/AzureIoTHub.Portal.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{3CA1
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{9EF190B3-41E2-48E1-BA4E-E129589DD250}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\arm-ttk.yml = ..\.github\workflows\arm-ttk.yml
..\.github\workflows\build.yml = ..\.github\workflows\build.yml
..\.github\workflows\codeql.yml = ..\.github\workflows\codeql.yml
..\.github\workflows\deploy_staging.yml = ..\.github\workflows\deploy_staging.yml
..\.github\workflows\publish-documentation-new-version.yml = ..\.github\workflows\publish-documentation-new-version.yml
..\.github\workflows\publish.yml = ..\.github\workflows\publish.yml
EndProjectSection
EndProject
Expand Down
32 changes: 32 additions & 0 deletions templates/portalDeployWithLoRa.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
}
},
"variables": {
"pgsqlServerName": "[concat(parameters('uniqueSolutionPrefix'), 'pgsql')]",
"pgsqlAdminLogin": "[concat(uniqueString(resourceGroup().id, newGuid()))]",
"pgsqlAdminPassword": "[concat(uniqueString(resourceGroup().id, newGuid()), 'x', '!')]",
"iotHubName": "[concat(parameters('uniqueSolutionPrefix'), 'hub')]",
"dpsName": "[concat(parameters('uniqueSolutionPrefix'), 'dps')]",
"siteName": "[concat(parameters('uniqueSolutionPrefix'), 'portal')]",
Expand Down Expand Up @@ -107,6 +110,30 @@
"allocationPolicy": "Hashed"
}
},
{
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name": "[variables('pgsqlServerName')]",
"location": "[parameters('location')]",
"sku": {
"name": "B_Gen5_1",
"tier": "Basic",
"capacity": "2",
"size": "5120",
"family": "Gen5"
},
"properties": {
"createMode": "Default",
"version": "11",
"administratorLogin": "[variables('pgsqlAdminLogin')]",
"administratorLoginPassword": "[variables('pgsqlAdminPassword')]",
"storageProfile": {
"storageMB": "2048",
"backupRetentionDays": "7",
"geoRedundantBackup": "false"
}
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2021-02-01",
Expand Down Expand Up @@ -182,6 +209,11 @@
"name": "LoRaKeyManagement__Code",
"type": "Custom",
"connectionString": "[listkeys(variables('functionAppDefaultHost'),'2021-02-01').masterKey]"
},
{
"name": "PostgreSQL__ConnectionString",
"type": "Custom",
"connectionString": "[concat('User ID=', variables('pgsqlAdminLogin'), ';Password=', variables('pgsqlAdminPassword'), ';Host=', concat(variables('pgsqlServerName'), '.postgres.database.azure.com') ,';Port=5432;Database=', variables('siteName') ,';Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;"
}
],
"appSettings": [
Expand Down
104 changes: 68 additions & 36 deletions templates/portalDeployWithoutLoRa.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
}
},
"variables": {
"pgsqlServerName": "[concat(parameters('uniqueSolutionPrefix'), 'pgsql')]",
"pgsqlAdminLogin": "[concat(uniqueString(resourceGroup().id, newGuid()))]",
"pgsqlAdminPassword": "[concat(uniqueString(resourceGroup().id, newGuid()), 'x', '!')]",
"iotHubName": "[concat(parameters('uniqueSolutionPrefix'), 'hub')]",
"dpsName": "[concat(parameters('uniqueSolutionPrefix'), 'dps')]",
"siteName": "[concat(parameters('uniqueSolutionPrefix'), 'portal')]",
Expand All @@ -81,17 +84,17 @@
},
"resources": [
{
"type": "Microsoft.Devices/IotHubs",
"apiVersion": "2021-07-02",
"sku": {
"name": "S1",
"tier": "Standard",
"capacity": 1
},
"name": "[variables('iotHubName')]",
"location": "[parameters('location')]",
"properties": {},
"dependsOn": []
"type": "Microsoft.Devices/IotHubs",
"apiVersion": "2021-07-02",
"sku": {
"name": "S1",
"tier": "Standard",
"capacity": 1
},
"name": "[variables('iotHubName')]",
"location": "[parameters('location')]",
"properties": {},
"dependsOn": []
},
{
"type": "Microsoft.Devices/provisioningServices",
Expand All @@ -118,38 +121,62 @@
]
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2021-09-01",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"accountType": "[variables('storageAccountType')]"
},
"dependsOn": []
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2021-09-01",
"location": "[parameters('location')]",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"properties": {
"accountType": "[variables('storageAccountType')]"
},
"dependsOn": []
},
{
"type": "Microsoft.Storage/storageAccounts/blobServices/containers",
"apiVersion": "2021-09-01",
"name": "[format('{0}/default/{1}', variables('storageAccountName'), variables('deviceImageContainerName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
]
},
{
"type": "Microsoft.Insights/components",
"kind": "web",
"name": "[variables('appInsightName')]",
"apiVersion": "2020-02-02",
"location": "[parameters('location')]",
"scale": null,
"properties": {
"Application_Type": "web"
},
"dependsOn": []
"type": "Microsoft.DBforPostgreSQL/servers",
"apiVersion": "2017-12-01",
"name": "[variables('pgsqlServerName')]",
"location": "[parameters('location')]",
"sku": {
"name": "B_Gen5_1",
"tier": "Basic",
"capacity": "2",
"size": "5120",
"family": "Gen5"
},
"properties": {
"createMode": "Default",
"version": "11",
"administratorLogin": "[variables('pgsqlAdminLogin')]",
"administratorLoginPassword": "[variables('pgsqlAdminPassword')]",
"storageProfile": {
"storageMB": "2048",
"backupRetentionDays": "7",
"geoRedundantBackup": "false"
}
}
},
{
"type": "Microsoft.Insights/components",
"kind": "web",
"name": "[variables('appInsightName')]",
"apiVersion": "2020-02-02",
"location": "[parameters('location')]",
"scale": null,
"properties": {
"Application_Type": "web"
},
"dependsOn": []
},
{
"type": "Microsoft.Web/serverfarms",
Expand Down Expand Up @@ -223,6 +250,11 @@
"name": "StorageAccount__ConnectionString",
"type": "Custom",
"connectionString": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountId'),'2015-05-01-preview').key1)]"
},
{
"name": "PostgreSQL__ConnectionString",
"type": "Custom",
"connectionString": "[concat('User ID=', variables('pgsqlAdminLogin'), ';Password=', variables('pgsqlAdminPassword'), ';Host=', concat(variables('pgsqlServerName'), '.postgres.database.azure.com') ,';Port=5432;Database=', variables('siteName') ,';Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;"
}
],
"appSettings": [
Expand Down

0 comments on commit 57207ba

Please sign in to comment.