Last active
May 25, 2021 12:58
-
-
Save atanasyanew/14e40a6700d3132d7c2e652dcf8a9a3c to your computer and use it in GitHub Desktop.
Azure arm template with - Storage account and Blob, MS SQL, App service plan, .NET Core API, Web app
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')]" | |
}, | |
"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'))]", | |
"sqlServerName": "[concat('sql-', parameters('projectName'), '-', parameters('environment'))]", | |
"sqlDbName": "[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'))]", | |
"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'))]" | |
] | |
} | |
] | |
}, | |
// SQL server and Database | |
{ | |
"type": "Microsoft.Sql/servers", | |
"apiVersion": "2020-02-02-preview", | |
"name": "[variables('sqlServerName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"administratorLogin": "[parameters('sqlAdministratorLogin')]", | |
"administratorLoginPassword": "[parameters('sqlAdministratorLoginPassword')]" | |
}, | |
"resources": [ | |
{ | |
"type": "databases", | |
"apiVersion": "2020-08-01-preview", | |
"name": "[variables('sqlDBName')]", | |
"location": "[parameters('location')]", | |
"sku": { | |
"name": "Standard", | |
"tier": "Standard", | |
"capacity": 10 | |
}, | |
"dependsOn": [ | |
"[resourceId('Microsoft.Sql/servers', variables('sqlServerName'))]" | |
] | |
}, | |
{ | |
"type": "firewallrules", | |
"apiVersion": "2020-02-02-preview", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Sql/servers', variables('sqlServerName'))]" | |
], | |
"location": "[parameters('location')]", | |
"name": "AllowAllWindowsAzureIps", | |
"properties": { | |
"endIpAddress": "0.0.0.0", | |
"startIpAddress": "0.0.0.0" | |
} | |
} | |
] | |
}, | |
// 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.Sql/servers', variables('sqlServerName'))]", | |
"[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" | |
} | |
} | |
} | |
] | |
}, | |
// 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