|
| 1 | +@description('The name of the Azure Container Registry') |
| 2 | +param acrName string |
| 3 | + |
| 4 | +@description('The SKU of the Azure Container Registry') |
| 5 | +param acrSku string |
| 6 | + |
| 7 | +@description('The name of the App Service Plan') |
| 8 | +param appServicePlanName string |
| 9 | + |
| 10 | +@description('The name of the Web App') |
| 11 | +param webAppName string |
| 12 | + |
| 13 | +@description('The location for all resources') |
| 14 | +param location string |
| 15 | + |
| 16 | +@description('The container image to deploy') |
| 17 | +param containerImage string |
| 18 | + |
| 19 | +// Deploy the Azure Container Registry |
| 20 | +resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = { |
| 21 | + name: acrName |
| 22 | + location: location |
| 23 | + sku: { |
| 24 | + name: acrSku |
| 25 | + } |
| 26 | + properties: { |
| 27 | + adminUserEnabled: true |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +// Deploy the App Service Plan |
| 32 | +resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = { |
| 33 | + name: appServicePlanName |
| 34 | + location: location |
| 35 | + sku: { |
| 36 | + name: 'S1' |
| 37 | + tier: 'Standard' |
| 38 | + } |
| 39 | + properties: { |
| 40 | + reserved: true // Indicates Linux |
| 41 | + } |
| 42 | +} |
| 43 | + |
| 44 | +// Deploy the Web App |
| 45 | +resource webApp 'Microsoft.Web/sites@2024-04-01' = { |
| 46 | + name: webAppName |
| 47 | + location: location |
| 48 | + identity: { |
| 49 | + type: 'SystemAssigned' |
| 50 | + } |
| 51 | + tags: { |
| 52 | + 'azd-service-name': webAppName |
| 53 | + } |
| 54 | + properties: { |
| 55 | + serverFarmId: appServicePlan.id |
| 56 | + siteConfig: { |
| 57 | + appSettings: [ |
| 58 | + { |
| 59 | + name: 'DOCKER_REGISTRY_SERVER_URL' |
| 60 | + value: 'https://${acr.name}.azurecr.io' |
| 61 | + } |
| 62 | + { |
| 63 | + name: 'DOCKER_REGISTRY_SERVER_USERNAME' |
| 64 | + value: acr.properties.loginServer |
| 65 | + } |
| 66 | + { |
| 67 | + name: 'DOCKER_REGISTRY_SERVER_PASSWORD' |
| 68 | + value: acr.listCredentials().passwords[0].value |
| 69 | + } |
| 70 | + { |
| 71 | + name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' |
| 72 | + value: 'false' |
| 73 | + } |
| 74 | + { |
| 75 | + name: 'DOCKER_CUSTOM_IMAGE_NAME' |
| 76 | + value: containerImage |
| 77 | + } |
| 78 | + ] |
| 79 | + linuxFxVersion: 'DOCKER|${containerImage}' // Specify the container image |
| 80 | + } |
| 81 | + } |
| 82 | +} |
0 commit comments