bicep如何同时部署App Service + Certificate + hostbinding?
How to deploy App Service + Certificate + hostbinding at the same time with bicep?
我在使用此代码同时部署带有证书的 hostNameBinding 时遇到问题:
param appserviceplanId string
param location string
param appservicename string
param domain string
resource appservice 'Microsoft.Web/sites@2020-12-01' = {
name: appservicename
location: location
properties: {
serverFarmId: appserviceplanId
enabled: true
httpsOnly: true
siteConfig: {
use32BitWorkerProcess: false
webSocketsEnabled: true
alwaysOn: true
http20Enabled: true
autoHealEnabled: true
netFrameworkVersion: 'v5.0'
}
clientAffinityEnabled: false
}
}
resource certificate 'Microsoft.Web/certificates@2021-01-01' = {
name: '${domain}-certificate'
location: location
properties: {
canonicalName: domain
serverFarmId: appserviceplanId
domainValidationMethod: 'http-token'
}
}
resource hostbinding 'Microsoft.Web/sites/hostNameBindings@2021-01-01' = {
parent: appservice
name: domain
properties: {
siteName: appservicename
customHostNameDnsRecordType: 'CName'
hostNameType: 'Verified'
sslState: 'SniEnabled'
thumbprint: certificate.properties.thumbprint
}
}
只有在我通过注释掉证书逐步部署它时它才有效:
param appserviceplanId string
param location string
param appservicename string
param domain string
resource appservice 'Microsoft.Web/sites@2020-12-01' = {
name: appservicename
location: location
properties: {
serverFarmId: appserviceplanId
customDomainVerificationId: 'DNS Record verification'
enabled: true
httpsOnly: true
siteConfig: {
use32BitWorkerProcess: false
webSocketsEnabled: true
alwaysOn: true
http20Enabled: true
autoHealEnabled: true
netFrameworkVersion: 'v5.0'
}
clientAffinityEnabled: false
}
}
// resource certificate 'Microsoft.Web/certificates@2021-01-01' = {
// name: '${domain}-certificate'
// location: location
// properties: {
// canonicalName: domain
// serverFarmId: appserviceplanId
// domainValidationMethod: 'http-token'
// }
// }
resource hostbinding 'Microsoft.Web/sites/hostNameBindings@2021-01-01' = {
parent: appservice
name: domain
properties: {
siteName: appservicename
customHostNameDnsRecordType: 'CName'
hostNameType: 'Verified'
// sslState: 'SniEnabled'
// thumbprint: certificate.properties.thumbprint
}
}
在此之后我可以 运行 整个事情,因为主机绑定存在。
怎样才能一次性完成?
因此,没有证书就无法进行主机绑定,没有主机绑定就无法进行证书,loop di loop。
如果我在证书资源之前指定 HostBinding,然后在具有属性的证书之后再次指定,我得到 'HostName is specified more then once'。
我在使用此代码同时部署带有证书的 hostNameBinding 时遇到问题:
param appserviceplanId string
param location string
param appservicename string
param domain string
resource appservice 'Microsoft.Web/sites@2020-12-01' = {
name: appservicename
location: location
properties: {
serverFarmId: appserviceplanId
enabled: true
httpsOnly: true
siteConfig: {
use32BitWorkerProcess: false
webSocketsEnabled: true
alwaysOn: true
http20Enabled: true
autoHealEnabled: true
netFrameworkVersion: 'v5.0'
}
clientAffinityEnabled: false
}
}
resource certificate 'Microsoft.Web/certificates@2021-01-01' = {
name: '${domain}-certificate'
location: location
properties: {
canonicalName: domain
serverFarmId: appserviceplanId
domainValidationMethod: 'http-token'
}
}
resource hostbinding 'Microsoft.Web/sites/hostNameBindings@2021-01-01' = {
parent: appservice
name: domain
properties: {
siteName: appservicename
customHostNameDnsRecordType: 'CName'
hostNameType: 'Verified'
sslState: 'SniEnabled'
thumbprint: certificate.properties.thumbprint
}
}
只有在我通过注释掉证书逐步部署它时它才有效:
param appserviceplanId string
param location string
param appservicename string
param domain string
resource appservice 'Microsoft.Web/sites@2020-12-01' = {
name: appservicename
location: location
properties: {
serverFarmId: appserviceplanId
customDomainVerificationId: 'DNS Record verification'
enabled: true
httpsOnly: true
siteConfig: {
use32BitWorkerProcess: false
webSocketsEnabled: true
alwaysOn: true
http20Enabled: true
autoHealEnabled: true
netFrameworkVersion: 'v5.0'
}
clientAffinityEnabled: false
}
}
// resource certificate 'Microsoft.Web/certificates@2021-01-01' = {
// name: '${domain}-certificate'
// location: location
// properties: {
// canonicalName: domain
// serverFarmId: appserviceplanId
// domainValidationMethod: 'http-token'
// }
// }
resource hostbinding 'Microsoft.Web/sites/hostNameBindings@2021-01-01' = {
parent: appservice
name: domain
properties: {
siteName: appservicename
customHostNameDnsRecordType: 'CName'
hostNameType: 'Verified'
// sslState: 'SniEnabled'
// thumbprint: certificate.properties.thumbprint
}
}
在此之后我可以 运行 整个事情,因为主机绑定存在。
怎样才能一次性完成?
因此,没有证书就无法进行主机绑定,没有主机绑定就无法进行证书,loop di loop。
如果我在证书资源之前指定 HostBinding,然后在具有属性的证书之后再次指定,我得到 'HostName is specified more then once'。