+1
.gitignore
+1
.gitignore
+30
deploymentBindingHack.bicep
+30
deploymentBindingHack.bicep
···
1
+
// https://stackoverflow.com/questions/73077972/how-to-deploy-app-service-with-managed-ssl-certificate-using-arm
2
+
//
3
+
// TLDR: Azure requires a circular dependency in order to define an app service with a custom domain with SSL enabled.
4
+
// Terrific user experience. Really makes me love using Azure in my free time.
5
+
param webAppName string
6
+
param location string
7
+
param appServicePlanResourceId string
8
+
param customHostnames array
9
+
10
+
// Managed certificates can only be created once the hostname is added to the web app.
11
+
resource certificates 'Microsoft.Web/certificates@2022-03-01' = [for (fqdn, i) in customHostnames: {
12
+
name: '${fqdn}-${webAppName}'
13
+
location: location
14
+
properties: {
15
+
serverFarmId: appServicePlanResourceId
16
+
canonicalName: fqdn
17
+
}
18
+
}]
19
+
20
+
// sslState and thumbprint can only be set once the managed certificate is created
21
+
@batchSize(1)
22
+
resource customHostname 'Microsoft.web/sites/hostnameBindings@2019-08-01' = [for (fqdn, i) in customHostnames: {
23
+
name: '${webAppName}/${fqdn}'
24
+
properties: {
25
+
siteName: webAppName
26
+
hostNameType: 'Verified'
27
+
sslState: 'SniEnabled'
28
+
thumbprint: certificates[i].properties.thumbprint
29
+
}
30
+
}]