|
| 1 | +@description('The location into which your Azure resources should be deployed.') |
| 2 | +param location string = resourceGroup().location |
| 3 | + |
| 4 | +@description('Select the type of environment you want to provision. Allowed values are Production and Test.') |
| 5 | +@allowed([ |
| 6 | + 'Production' |
| 7 | + 'Test' |
| 8 | +]) |
| 9 | +param environmentType string |
| 10 | + |
| 11 | +@description('A unique suffix to add to resource names that need to be globally unique.') |
| 12 | +@maxLength(13) |
| 13 | +param resourceNameSuffix string = uniqueString(resourceGroup().id) |
| 14 | + |
| 15 | +param storageAccountNameParam string = uniqueString(resourceGroup().id) |
| 16 | + |
| 17 | +// Define the names for resources. |
| 18 | +var appServiceAppName = 'toy-website-${resourceNameSuffix}' |
| 19 | +var appServicePlanName = 'toy-website' |
| 20 | +var applicationInsightsName = 'toywebsite' |
| 21 | +var storageAccountName = 'mystorageresourceNameSuffix' |
| 22 | + |
| 23 | +// Define the SKUs for each component based on the environment type. |
| 24 | +var environmentConfigurationMap = { |
| 25 | + Production: { |
| 26 | + appServicePlan: { |
| 27 | + sku: { |
| 28 | + name: 'S1' |
| 29 | + capacity: 1 |
| 30 | + } |
| 31 | + } |
| 32 | + } |
| 33 | + Test: { |
| 34 | + appServicePlan: { |
| 35 | + sku: { |
| 36 | + name: 'F1' |
| 37 | + } |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +resource appServicePlan 'Microsoft.Web/serverfarms@2021-01-15' = { |
| 43 | + name: appServicePlanName |
| 44 | + location: location |
| 45 | + sku: environmentConfigurationMap[environmentType].appServicePlan.sku |
| 46 | +} |
| 47 | + |
| 48 | +resource appServiceApp 'Microsoft.Web/sites@2021-01-15' = { |
| 49 | + name: appServiceAppName |
| 50 | + location: location |
| 51 | + properties: { |
| 52 | + serverFarmId: appServicePlan.id |
| 53 | + siteConfig: { |
| 54 | + appSettings: [ |
| 55 | + { |
| 56 | + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' |
| 57 | + value: applicationInsights.properties.InstrumentationKey |
| 58 | + } |
| 59 | + { |
| 60 | + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' |
| 61 | + value: applicationInsights.properties.ConnectionString |
| 62 | + } |
| 63 | + ] |
| 64 | + } |
| 65 | + } |
| 66 | +} |
| 67 | + |
| 68 | +resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = { |
| 69 | + name: applicationInsightsName |
| 70 | + location: location |
| 71 | + kind: 'web' |
| 72 | + properties: { |
| 73 | + Application_Type: 'web' |
| 74 | + Request_Source: 'rest' |
| 75 | + Flow_Type: 'Bluefield' |
| 76 | + } |
| 77 | +} |
| 78 | + |
| 79 | +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = { |
| 80 | + name: storageAccountName |
| 81 | + location: location |
| 82 | + kind: 'StorageV2' |
| 83 | + sku: { |
| 84 | + name: 'Standard_LRS' |
| 85 | + } |
| 86 | +} |
| 87 | + |
| 88 | +output appServiceAppHostName string = appServiceApp.properties.defaultHostName |
0 commit comments