|
| 1 | +metadata description = 'Creates an Azure App Service in an existing Azure App Service plan.' |
| 2 | +param name string |
| 3 | +param location string = resourceGroup().location |
| 4 | +param tags object = {} |
| 5 | + |
| 6 | +// Reference Properties |
| 7 | +param applicationInsightsName string = '' |
| 8 | +param appServicePlanId string |
| 9 | +param keyVaultName string = '' |
| 10 | +param managedIdentity bool = !empty(keyVaultName) |
| 11 | + |
| 12 | +// Runtime Properties |
| 13 | +@allowed([ |
| 14 | + 'dotnet', 'dotnetcore', 'dotnet-isolated', 'node', 'python', 'java', 'powershell', 'custom' |
| 15 | +]) |
| 16 | +param runtimeName string |
| 17 | +param runtimeNameAndVersion string = '${runtimeName}|${runtimeVersion}' |
| 18 | +param runtimeVersion string |
| 19 | + |
| 20 | +// Microsoft.Web/sites Properties |
| 21 | +param kind string = 'app,linux' |
| 22 | + |
| 23 | +// Microsoft.Web/sites/config |
| 24 | +param allowedOrigins array = [] |
| 25 | +param alwaysOn bool = true |
| 26 | +param appCommandLine string = '' |
| 27 | +@secure() |
| 28 | +param appSettings object = {} |
| 29 | +param clientAffinityEnabled bool = false |
| 30 | +param enableOryxBuild bool = contains(kind, 'linux') |
| 31 | +param functionAppScaleLimit int = -1 |
| 32 | +param linuxFxVersion string = runtimeNameAndVersion |
| 33 | +param minimumElasticInstanceCount int = -1 |
| 34 | +param numberOfWorkers int = -1 |
| 35 | +param scmDoBuildDuringDeployment bool = false |
| 36 | +param use32BitWorkerProcess bool = false |
| 37 | +param ftpsState string = 'FtpsOnly' |
| 38 | +param healthCheckPath string = '' |
| 39 | + |
| 40 | +resource appService 'Microsoft.Web/sites@2022-03-01' = { |
| 41 | + name: name |
| 42 | + location: location |
| 43 | + tags: tags |
| 44 | + kind: kind |
| 45 | + properties: { |
| 46 | + serverFarmId: appServicePlanId |
| 47 | + siteConfig: { |
| 48 | + linuxFxVersion: linuxFxVersion |
| 49 | + alwaysOn: alwaysOn |
| 50 | + ftpsState: ftpsState |
| 51 | + minTlsVersion: '1.2' |
| 52 | + appCommandLine: appCommandLine |
| 53 | + numberOfWorkers: numberOfWorkers != -1 ? numberOfWorkers : null |
| 54 | + minimumElasticInstanceCount: minimumElasticInstanceCount != -1 ? minimumElasticInstanceCount : null |
| 55 | + use32BitWorkerProcess: use32BitWorkerProcess |
| 56 | + functionAppScaleLimit: functionAppScaleLimit != -1 ? functionAppScaleLimit : null |
| 57 | + healthCheckPath: healthCheckPath |
| 58 | + cors: { |
| 59 | + allowedOrigins: union([ 'https://portal.azure.com', 'https://ms.portal.azure.com' ], allowedOrigins) |
| 60 | + } |
| 61 | + } |
| 62 | + clientAffinityEnabled: clientAffinityEnabled |
| 63 | + httpsOnly: true |
| 64 | + } |
| 65 | + |
| 66 | + identity: { type: managedIdentity ? 'SystemAssigned' : 'None' } |
| 67 | + |
| 68 | + resource configLogs 'config' = { |
| 69 | + name: 'logs' |
| 70 | + properties: { |
| 71 | + applicationLogs: { fileSystem: { level: 'Verbose' } } |
| 72 | + detailedErrorMessages: { enabled: true } |
| 73 | + failedRequestsTracing: { enabled: true } |
| 74 | + httpLogs: { fileSystem: { enabled: true, retentionInDays: 1, retentionInMb: 35 } } |
| 75 | + } |
| 76 | + } |
| 77 | + |
| 78 | + resource basicPublishingCredentialsPoliciesFtp 'basicPublishingCredentialsPolicies' = { |
| 79 | + name: 'ftp' |
| 80 | + properties: { |
| 81 | + allow: false |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + resource basicPublishingCredentialsPoliciesScm 'basicPublishingCredentialsPolicies' = { |
| 86 | + name: 'scm' |
| 87 | + properties: { |
| 88 | + allow: false |
| 89 | + } |
| 90 | + } |
| 91 | +} |
| 92 | + |
| 93 | +module config 'appservice-appsettings.bicep' = if (!empty(appSettings)) { |
| 94 | + name: '${name}-appSettings' |
| 95 | + params: { |
| 96 | + name: appService.name |
| 97 | + appSettings: union(appSettings, |
| 98 | + { |
| 99 | + SCM_DO_BUILD_DURING_DEPLOYMENT: string(scmDoBuildDuringDeployment) |
| 100 | + ENABLE_ORYX_BUILD: string(enableOryxBuild) |
| 101 | + }, |
| 102 | + runtimeName == 'python' && appCommandLine == '' ? { PYTHON_ENABLE_GUNICORN_MULTIWORKERS: 'true' } : {}, |
| 103 | + !empty(applicationInsightsName) ? { APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString } : {}, |
| 104 | + !empty(keyVaultName) ? { AZURE_KEY_VAULT_ENDPOINT: keyVault.properties.vaultUri } : {}) |
| 105 | + } |
| 106 | +} |
| 107 | + |
| 108 | +resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(keyVaultName))) { |
| 109 | + name: keyVaultName |
| 110 | +} |
| 111 | + |
| 112 | +resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = if (!empty(applicationInsightsName)) { |
| 113 | + name: applicationInsightsName |
| 114 | +} |
| 115 | + |
| 116 | +output identityPrincipalId string = managedIdentity ? appService.identity.principalId : '' |
| 117 | +output name string = appService.name |
| 118 | +output uri string = 'https://${appService.properties.defaultHostName}' |
0 commit comments