如何解决如何使用 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
}
}
在此之后,我可以运行整个程序,因为 Hostbinding 存在。
我怎样才能一次性完成?
所以,没有证书就不能制作Hostbinding,没有hostbinding就不能制作证书,loop di loop。
如果我在证书资源之前指定 HostBinding,然后在具有属性的证书之后再次指定 HostBinding,我会得到“HostName 被指定多次”。
解决方法
你需要使用模块。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。