|
param location string = resourceGroup().location |
|
|
|
param webAppName string = 'vm-redirapp' |
|
param sku string = 'B2' |
|
param linuxFxVersion string = 'PHP|8.3' |
|
|
|
|
|
@description('Domains that are validated in DNS but not deployed yet.') |
|
param validatedDomains array = [ |
|
'test3.mach.im' |
|
'test4.mach.im' |
|
'test5.mach.im' |
|
'test6.mach.im' |
|
] |
|
|
|
@description('Domains that are validated in DNS and have also a certificate in Azure deployed.') |
|
param domainsWithCertificate array = [ |
|
'test3.mach.im' |
|
'test4.mach.im' |
|
'test5.mach.im' |
|
] |
|
|
|
var appServicePlanName = toLower('asp-${webAppName}') |
|
var webSiteName = toLower('wapp-${webAppName}') |
|
|
|
resource plan 'Microsoft.Web/serverfarms@2020-06-01' = { |
|
name: appServicePlanName |
|
location: location |
|
properties: { |
|
reserved: true |
|
} |
|
sku: { |
|
name: sku |
|
} |
|
kind: 'linux' |
|
} |
|
|
|
resource site 'Microsoft.Web/sites@2024-04-01' = { |
|
name: webSiteName |
|
location: location |
|
properties: { |
|
serverFarmId: plan.id |
|
siteConfig: { |
|
linuxFxVersion: linuxFxVersion |
|
} |
|
} |
|
} |
|
|
|
output verificationRecord string = site.properties.customDomainVerificationId |
|
output defaultHostName string = site.properties.defaultHostName |
|
output inboundIp string = site.properties.inboundIpAddress |
|
|
|
@description('These DNS records need to be added to zone before creating bindings.') |
|
var customDns = flatten(map(validatedDomains, domain => [ |
|
'asuid.${domain} TXT ${site.properties.customDomainVerificationId}' |
|
'${domain} CNAME ${site.properties.defaultHostName}' |
|
])) |
|
output customDnsRecords array = customDns |
|
|
|
@batchSize(1) |
|
resource binding 'Microsoft.Web/sites/hostNameBindings@2019-08-01' = [ |
|
for domain in validatedDomains: { |
|
name: domain |
|
parent: site |
|
properties: { |
|
siteName: site.name |
|
hostNameType: 'Verified' |
|
sslState: contains(domainsWithCertificate, domain) ? 'SniEnabled' : 'Disabled' |
|
} |
|
} |
|
] |
|
|
|
resource certificate 'Microsoft.Web/certificates@2021-01-15' = [ |
|
for domain in validatedDomains: { |
|
name: '${webSiteName}-${domain}' |
|
location: resourceGroup().location |
|
properties: { |
|
serverFarmId: plan.id |
|
hostNames: [ |
|
domain |
|
] |
|
canonicalName: domain |
|
} |
|
|
|
dependsOn: [ |
|
binding |
|
] |
|
} |
|
] |