azure - 使用应用服务证书的 Azure ARM SSL 绑定
问题描述
我有一个在 ARM 模板中使用 hostnameBindings 配置的自定义主机名的站点。这部署得很好。
我还从 Azure 创建并验证了 SSL 证书,并带有相应的指纹。
在 Azure 站点中,我还可以将证书绑定到应用服务。
但是,当我使用 ARM 模板从 hostnameBindings 中的模板分配 SSL 时,它会给出一个错误,即找不到证书...
我不明白出了什么问题...
我的猜测:
- 该证书位于不同的资源组中,因此无法找到,但在模板设置中我无法设置该组。
- 在 Azure 网站中,我可以使用我必须导入的 SSL,所以也许我在 ARM 模板中缺少这一步?
- 使用错误的指纹?
在 hostnameBindings 我只定义指纹和 sslState
知道我错过了哪一步吗?
谢谢你
更新
我的参数json文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.5.0.8",
"parameters": {
"baseResourceName": {
"value": "base-name"
},
"environments": {
"value": [
"preview"
]
},
"hostNames": {
"value": [
{
"name": "myhostname.example.com",
"sslState": "SniEnabled",
"thumbprint": "9897LKJL88KHKJH8888KLJLJLJLKJLJLKL4545"
},
{
"name": "myhostname2.example.com"
}
]
},
"ipSecurityRestrictions": {
"value": []
}
}
}
我的模板 json 文件:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.5.0.8",
"parameters": {
"hostName": {
"defaultValue": [],
"type": "array",
"metadata": {
"description": "The custom hostnames of sites"
}
}
},
"variables": {
"standardPlanMaxAdditionalSlots": 4,
"appName": "[concat(parameters('baseResourceName'), '-private')]",
"appServicePlanName": "[concat(parameters('baseResourceName'), '-appServicePlan')]",
"appInsightName": "[concat(parameters('baseResourceName'), '-appInsight')]",
"ipSecurityRestrictions": "[parameters('ipSecurityRestrictions')]"
},
"resources": [
{
"type": "Microsoft.Web/serverfarms",
"comments": "AppPlan for app.",
"sku": {
"name": "[if(lessOrEquals(length(parameters('environments')), variables('standardPlanMaxAdditionalSlots')), 'S1', 'P1')]"
},
"tags": {
"displayName": "AppServicePlan-Private"
},
"name": "[variables('appServicePlanName')]",
"kind": "app",
"apiVersion": "2016-09-01",
"location": "[resourceGroup().location]",
"properties": {},
"dependsOn": []
},
{
"type": "Microsoft.Web/sites",
"comments": "This is the private web app.",
"kind": "app",
"apiVersion": "2016-03-01",
"name": "[variables('appName')]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "WebApp"
},
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"siteConfig": {
"appSettings": [],
"phpVersion": "",
"ipSecurityRestrictions": "[variables('ipSecurityRestrictions')]",
"http20Enabled": true,
"minTlsVersion": "1.2"
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
"[resourceId('microsoft.insights/components/', variables('appInsightName'))]"
]
},
{
"type": "Microsoft.Web/sites/hostnameBindings",
"name": "[concat(variables('appName'), '/', parameters('hostName')[copyIndex()].Name)]",
"apiVersion": "2016-03-01",
"location": "[resourceGroup().location]",
"properties": "[parameters('hostName')[copyIndex()]]",
"condition": "[greater(length(parameters('hostName')), 0)]",
"copy": {
"name": "hostnameCopy",
"count": "[length(parameters('hostName'))]",
"mode": "Serial"
},
"dependsOn": [
"[concat('Microsoft.Web/sites/',variables('appName'))]"
]
}
]
}
解决方案
greater(..., 0)
完全不相关,您是否使用零长度数组测试了您的条件?很确定它会爆炸。
就此主题而言。如果您将证书资源链接到应用服务计划,我认为您可能会使其工作。所以这是对证书资源执行的操作。如果您使用 keyvault 存储证书,这是完全可能的
{
"apiVersion": "2016-03-01",
"name": "[variables('certificateName')]",
"location": "[resourceGroup().location]",
"type": "Microsoft.Web/certificates",
"dependsOn": [
"[parameters('appServicePlan')]"
],
"properties": {
"keyVaultId": "kvResourceId",
"keyVaultSecretName": "secretName",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlan'))]"
}
}
推荐阅读
- java - Android中的向下钻取饼图
- eclipse - Eclipse:防止“文件搜索”在同一选项卡中打开不同的文件
- java - 难道我们没有任何Java内置方法来查找数字数组的平均值吗?
- apache-kafka - 具有多个主题的 Kafka MQTT 连接器
- javascript - POST 值到另一个应用程序
- arcgis - 我的点绘制在 0 纬度,0 经度
- c# - 使用MediaCapture c#在触发前后记录秒数的圆形缓冲区
- javascript - 在 VueJS 项目中安装 slick carousel
- javascript - 流式传输 html5 画布内容的有效方式?
- docker - 即使在配置 DOCKER_OPTS="iptables=false" 之后,ubuntu 18.04 服务器 ufw 也不会阻塞