Created
May 25, 2021 12:55
-
-
Save atanasyanew/e6ef5d8c1053feb779df23272480d51f to your computer and use it in GitHub Desktop.
Azure arm template with - Storage account and Blob, PostgreSQL, App service plan, .NET Core API, Web app Angular
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.1", | |
"parameters": { | |
"location": { | |
"type": "string", | |
"defaultValue": "[resourceGroup().location]", | |
"metadata": { | |
"description": "Location used for the createtion of the resources." | |
} | |
}, | |
"projectName": { | |
"type": "string", | |
"defaultValue": "nameoftheproject", | |
"minLength": 3, | |
"maxLength": 24, | |
"metadata": { | |
"description": "Used for naming the resources." | |
} | |
}, | |
"environment": { | |
"type": "string", | |
"defaultValue": "dev", | |
"metadata": { | |
"description": "Environment stage name for the deployment." | |
}, | |
"allowedValues": [ | |
"dev", | |
"qa", | |
"prod" | |
] | |
}, | |
"createdBy": { | |
"type": "string", | |
"defaultValue": "[email protected]" | |
}, | |
"createdOn": { | |
"type": "string", | |
"defaultValue": "[utcNow('yyyy-MM-dd')]" | |
}, | |
"psqlSkuName": { | |
"type": "string", | |
"defaultValue": "B_Gen5_2", | |
"metadata": { | |
"description": "The SKU (pricing tier) of the PostgreSQL server. <br> - Basic Gen5 2 vCore <br> - General Purpose Gen5 2 vCore" | |
}, | |
"allowedValues": [ | |
"B_Gen5_2", | |
"GP_Gen5_2" | |
] | |
}, | |
"sqlAdministratorLogin": { | |
"type": "string", | |
"defaultValue": "seraphim", | |
"metadata": { | |
"description": "The administrator username of the SQL logical server." | |
} | |
}, | |
"sqlAdministratorLoginPassword": { | |
"type": "securestring", | |
"defaultValue": "u=rimsinwt1", | |
"metadata": { | |
"description": "The administrator password of the SQL logical server." | |
} | |
}, | |
"storageSKU": { | |
"type": "string", | |
"defaultValue": "Standard_LRS", | |
"allowedValues": [ | |
"Standard_LRS", | |
"Standard_GRS", | |
"Standard_RAGRS", | |
"Standard_ZRS", | |
"Premium_LRS", | |
"Premium_ZRS", | |
"Standard_GZRS", | |
"Standard_RAGZRS" | |
], | |
"metadata": { | |
"description": "Approved SKUs for deployment." | |
} | |
}, | |
"appServicePlanSKU": { | |
"type": "string", | |
"defaultValue": "F1", | |
"allowedValues": [ | |
"F1", | |
"S1" | |
], | |
"metadata": { | |
"description": "Applications service plan SKU." | |
} | |
} | |
}, | |
"variables": { | |
"appServicePlanName": "[concat('asp-', parameters('projectName'), '-', parameters('environment'))]", | |
"psqlServerName": "[concat('sql-', parameters('projectName'), '-', parameters('environment'))]", | |
"psqlDbName": "[concat('sqldb-', parameters('projectName'), '-', parameters('environment'))]", | |
"storageAccountName": "[concat('st', parameters('projectName'), parameters('environment'))]", | |
"webApiName": "[concat('api-', parameters('projectName'), '-', parameters('environment'))]", | |
"webAppName": "[concat('app-', parameters('projectName'), '-', parameters('environment'))]", | |
"psqlBackupRetentionDays": 7, | |
"psqlInfrastructureEncryption": "Disabled", | |
"psqlGeoRedundantBackup": "Disabled", | |
"psqlStorageAutoGrow": "Enabled", | |
"resourceTags": { | |
"Environment": "[parameters('environment')]", | |
"CreatedBy": "[parameters('createdBy')]", | |
"CreatedOn": "[parameters('createdOn')]" | |
} | |
}, | |
"functions": [], | |
"resources": [ | |
// Storage account and Blob | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2021-01-01", | |
"name": "[variables('storageAccountName')]", | |
"location": "[parameters('location')]", | |
"tags": "[variables('resourceTags')]", | |
"kind": "StorageV2", | |
"sku": { | |
"name": "[parameters('storageSKU')]" | |
}, | |
"properties": { | |
"supportsHttpsTrafficOnly": true | |
}, | |
"resources": [ | |
{ | |
"type": "blobServices/containers", | |
"apiVersion": "2021-01-01", | |
"name": "/default/documents", | |
"properties": { | |
"publicAccess": "Container" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName'))]" | |
] | |
}, | |
{ | |
"type": "blobServices/containers", | |
"apiVersion": "2021-01-01", | |
"name": "/default/history-assets", | |
"properties": { | |
"publicAccess": "Container" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName'))]" | |
] | |
} | |
] | |
}, | |
// PostgreSQL | |
{ | |
"type": "Microsoft.DBforPostgreSQL/servers", | |
"apiVersion": "2017-12-01", | |
"tags": "[variables('resourceTags')]", | |
"location": "[parameters('location')]", | |
"name": "[variables('psqlServerName')]", | |
"properties": { | |
"version": "11", | |
"administratorLogin": "[parameters('sqlAdministratorLogin')]", | |
"administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]", | |
"storageProfile": { | |
"backupRetentionDays": "[variables('psqlBackupRetentionDays')]", | |
"geoRedundantBackup": "[variables('psqlGeoRedundantBackup')]", | |
"storageAutoGrow": "[variables('psqlStorageAutoGrow')]" | |
}, | |
"infrastructureEncryption": "[variables('psqlInfrastructureEncryption')]" | |
}, | |
"sku": { | |
"name": "[parameters('psqlSkuName')]" | |
}, | |
"resources": [ | |
// Database initialization. | |
{ | |
"type": "Microsoft.DBforPostgreSQL/servers/databases", | |
"apiversion": "2017-12-01", | |
"name": "[concat(variables('psqlServerName'), '/', variables('psqlDbName'))]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.DBforPostgreSQL/servers', variables('psqlServerName'))]" | |
], | |
"properties": { | |
"charset": "UTF8", | |
"collation": "English_United States.1252" | |
} | |
} | |
] | |
}, | |
// App service plan | |
{ | |
"type": "Microsoft.Web/serverfarms", | |
"apiVersion": "2018-02-01", | |
"name": "[variables('appServicePlanName')]", | |
"location": "[parameters('location')]", | |
"tags": "[variables('resourceTags')]", | |
"sku": { | |
"name": "[parameters('appServicePlanSKU')]" | |
}, | |
"kind": "app", | |
"properties": { | |
"perSiteScaling": false, | |
"maximumElasticWorkerCount": 1, | |
"isSpot": false, | |
"reserved": false, | |
"isXenon": false, | |
"hyperV": false, | |
"targetWorkerCount": 0, | |
"targetWorkerSizeId": 0 | |
} | |
}, | |
// Web app .NET Core API | |
{ | |
"type": "Microsoft.Web/sites", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('webApiName')]", | |
"location": "[parameters('location')]", | |
"tags": "[variables('resourceTags')]", | |
"kind": "app", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]", | |
"[resourceId('Microsoft.DBforPostgreSQL/servers', variables('psqlServerName'))]", | |
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" | |
], | |
"properties": { | |
"enabled": true, | |
"netFrameworkVersion": "v5.0", | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]", | |
"siteConfig": { | |
// "AlwaysOn": true, | |
// "apiDefinition": { | |
// "url": "[concat('https://', reference(concat('Microsoft.Web/sites/', variables('webApiName'))).defaultHostName, '/swagger/docs/v1')]" | |
// }, | |
// "cors": { | |
// "allowedOrigins": [ | |
// "*" | |
// ] | |
// }, | |
"appSettings": [ | |
{ | |
"name": "storageAccessKey", | |
"value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2021-01-01').keys[0].value]" | |
} | |
] | |
} | |
}, | |
"resources": [ | |
{ | |
"type": "config", | |
"name": "connectionstrings", | |
"apiVersion": "2018-11-01", | |
"tags": { | |
"displayName": "API Settings" | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('webApiName'))]" | |
], | |
"properties": { | |
// "DefaultConnection": { | |
// "value": "[concat('Data Source=tcp:', reference(resourceId('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('sqlDbName'), ';User Id=', parameters('sqlAdministratorLogin'), '@', reference(resourceId('Microsoft.Sql/servers/', variables('sqlserverName'))).fullyQualifiedDomainName, ';Password=', parameters('sqlAdministratorLoginPassword'), ';')]", | |
// "type": "SQLAzure" | |
// } | |
"defaultConnection": { | |
"value": "[concat('Database=', variables('psqlDbName'), ';Server=', variables('psqlServerName'), '.postgres.database.azure.com;User Id=', parameters('sqlAdministratorLogin'),'@', variables('psqlServerName'),';Password=', parameters('sqlAdministratorLoginPassword'))]", | |
"type": "PostgreSQL" | |
} | |
} | |
} | |
] | |
}, | |
// Web app Angular | |
{ | |
"type": "Microsoft.Web/sites", | |
"apiVersion": "2018-11-01", | |
"name": "[variables('webAppName')]", | |
"location": "[parameters('location')]", | |
"tags": "[variables('resourceTags')]", | |
"kind": "app", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
], | |
"properties": { | |
"enabled": true, | |
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]" | |
}, | |
"resources": [ | |
{ | |
"type": "config", | |
"name": "appsettings", | |
"apiVersion": "2018-11-01", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Web/sites', variables('webAppName'))]", | |
"[resourceId('Microsoft.Web/sites', variables('webApiName'))]" | |
], | |
"tags": { | |
"displayName": "Web Settings" | |
}, | |
"properties": { | |
"environment": "[parameters('environment')]", | |
"apiUrl": "[concat('https://', reference(concat('Microsoft.Web/sites/', variables('webApiName'))).defaultHostName)]" | |
} | |
} | |
] | |
} | |
], | |
// virtual network | |
// key vault | |
"outputs": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment