如何通过Azure ARM模板将证书上载到应用程序网关

如何通过Azure ARM模板将证书上载到应用程序网关,azure,arm-template,Azure,Arm Template,我正在尝试通过ARM模板脚本将证书上载到app gateway。如何通过ARM脚本实现这一点。以下是我的脚本: "backendHttpSettingsCollection": [ { "name": "appGatewayBackendHttpSettings", "properties": { "Por

我正在尝试通过ARM模板脚本将证书上载到app gateway。如何通过ARM脚本实现这一点。以下是我的脚本:

"backendHttpSettingsCollection": [
                    {
                        "name": "appGatewayBackendHttpSettings",
                        "properties": {
                            "Port": 80,
                            "Protocol": "Http",
                            "CookieBasedAffinity": "Disabled"
                        }
                    },
                    {
                        "name": "httpssettings",
                        "etag": "W/\"f5659c7c-d83a-431b-b456-097622a27c7b\"",
                        "properties": {
                            "provisioningState": "Succeeded",
                            "port": 8443,
                            "protocol": "Https",
                            "cookieBasedAffinity": "Enabled",
                            "connectionDraining": {
                                "enabled": false,
                                "drainTimeoutInSec": 60
                            },
                            "pickHostNameFromBackendAddress": false,
                            "path": null,
                            "requestTimeout": 300,
                            "authenticationCertificates": [
                                {
                                    "id": "[parameters('sslCertData')]"
                                }
                            ]
                        },
                        "type": "Microsoft.Network/applicationGateways/backendHttpSettingsCollection"
                    },
                    {
                        "name": "scalablehttpsettings",
                        "etag": "W/\"f5659c7c-d83a-431b-b456-097622a27c7b\"",
                        "properties": {
                            "provisioningState": "Succeeded",
                            "port": 7443,
                            "protocol": "Https",
                            "cookieBasedAffinity": "Enabled",
                            "connectionDraining": {
                                "enabled": false,
                                "drainTimeoutInSec": 60
                            },
                            "pickHostNameFromBackendAddress": false,
                            "path": null,
                            "requestTimeout": 300,
                            "authenticationCertificates": [
                                {
                                    "id": "[parameters('sslCertData')]"
                                }
                            ]
                        },
                        "type": "Microsoft.Network/applicationGateways/backendHttpSettingsCollection"
                    }
                ],
我想知道如何为authenticationCertificates下的参数('sslCertData')提供证书路径。有人能帮我吗


PS:证书采用.cer格式。

您不能直接执行此操作。您需要将证书转换为base64,并将其作为base64传递给应用程序网关。另外,我相当肯定您不能对侦听器使用
.cer
,只能对auth使用(所以是端到端ssl)。工作示例:

"sslCertificates": [ // these certificates can be used for listeners
    {
        "name": "offloadCertificate",
        "properties": {
            "data": "base64_value_of_.pfx",
            "password": "password_for_.pfx"
        }
    }
],
"authenticationCertificates": [ // these only for end-to-end ssl
    {
        "name": "authenticationCertificate",
        "properties": {
            "data": "base64_value_of_.cer"
        }
    }
]

我将其转换为base 64并将其添加到authenticationCertificates。但是,当我执行脚本时,它正在抛出新的AzureRmResourceGroupDeployment:23:24:26-Resource Microsoft.Network/applicationGateways'VVVgateway'失败,并显示消息“{”error:{”code:“InvalidRequestFormat”,“message:“无法解析请求”,“详细信息”:[{”code:“InvalidJsonReferenceFormat”,格式不正确。请对此提供帮助。在不知道模板外观的情况下,无法提供帮助,如果是上面的情况,您确实需要删除所有额外属性,例如:模板正确,它在身份验证证书上抛出错误:properties.backendHttpSettingsCollection[1].properties.authenticationCertificates。我认为转换后的base64格式不正确。可能是证书有问题,或者转换后的base64密钥有问题吗?有什么想法吗?有人能帮我吗?我已经告诉过你怎么做了
We have to use and declare as shown below. It works like a charm.

"httpscertificate": { 
        "defaultValue":"Base64 converted value"
    "type": "string"
        },

"authenticationCertificates": [
                    {
                        "properties": {
                            "data": "[parameters('httpscertificate')]"
                        },
                        "name": "Appgatewaybackendcert"
                    }
                ],

"backendHttpSettingsCollection": [
                    {
                        "name": "appGatewayBackendHttpSettings",
                        "properties": {
                            "Port": 80,
                            "Protocol": "Http",
                            "CookieBasedAffinity": "Disabled"
                        }
                    },
                    {
                        "name": "nonscalablehttpssettings",
                        "etag": "W/\"f5659c7c-d83a-431b-b456-097622a27c7b\"",
                        "properties": {
                            "provisioningState": "Succeeded",
                            "port": 8443,
                            "protocol": "Https",
                            "cookieBasedAffinity": "Disabled",
                            "connectionDraining": {
                                "enabled": false,
                                "drainTimeoutInSec": 60
                            },
                            "pickHostNameFromBackendAddress": false,
                            "path": null,
                            "requestTimeout": 300,
                            "authenticationCertificates": [
                                {
                                    "Id": "[concat(variables('applicationGatewayID'), '/authenticationCertificates/checkpointsystems')]" //appGatewayBackendCert
                                }
                            ]
                        },
                        "type": "Microsoft.Network/applicationGateways/backendHttpSettingsCollection"
                    },
                    {
                        "name": "scalablehttpsettings",
                        "etag": "W/\"f5659c7c-d83a-431b-b456-097622a27c7b\"",
                        "properties": {
                            "provisioningState": "Succeeded",
                            "port": 7443,
                            "protocol": "Https",
                            "cookieBasedAffinity": "Disabled",
                            "connectionDraining": {
                                "enabled": false,
                                "drainTimeoutInSec": 60
                            },
                            "pickHostNameFromBackendAddress": false,
                            "path": null,
                            "requestTimeout": 300,
                            "authenticationCertificates": [
                                {
                                    "Id": "[concat(variables('applicationGatewayID'), '/authenticationCertificates/checkpointsystems')]"
                                }
                            ]
                        },
                        "type": "Microsoft.Network/applicationGateways/backendHttpSettingsCollection"
                    }
                ],