【问题标题】:Possible to get an Azure Function systemkey in an ARM template?可以在 ARM 模板中获取 Azure Function 系统密钥吗?
【发布时间】:2018-05-23 21:00:14
【问题描述】:

我知道我可以通过使用 listKeys/listSecrets 方法在 ARM 模板中获取 Azure 函数的主机密钥和 trigger_url。 但我需要系统密钥,我正在部署一个事件网格订阅,它需要包含系统密钥的 Azure 函数端点 url:

"resources": [
        {
            "type": "Microsoft.Storage/StorageAccounts/providers/eventSubscriptions",
            "name": "[concat(concat(parameters('publisherName'), '/Microsoft.EventGrid/'), parameters('name'))]",
            "apiVersion": "2018-01-01",
            "properties": {
                "destination": {
                    "endpointType": "[parameters('endpointType')]",
                    "properties": {
                        "endpointUrl": "[parameters('endpointUrl')]"
                    }
                },
                "filter": {
                    "subjectBeginsWith": "[parameters('subjectBeginsWith')]",
                    "subjectEndsWith": "[parameters('subjectEndsWith')]",
                    "subjectIsCaseSensitive": "[parameters('subjectIsCaseSensitive')]",
                    "includedEventTypes": "[parameters('includedEventTypes')]"
                },
                "labels": "[parameters('labels')]"
            }
        }
    ]

endpointUrl 的形式为:

https://<function-app-name>.azurewebsites.net/admin/extensions/EventGridExtensionConfig?functionName=<function-name>&code=XZvGU0ROPxxxxxxxxxxxxxxxxxxxxxxxxxxxxaaieD89gPQ==

名为'code'的参数是systemkey,可以通过GET方法获取

http://<function-app-name>.azurewebsites.net/admin/host/systemkeys/eventgridextensionconfig_extension?code=<master_key>

有没有办法在 ARM 模板中检索此系统密钥(或整个端点 URL),而无需借助注入它的 bash 脚本或其他外部系统?

文档确实说:“但是,您不能使用需要请求正文中的值的列表操作。”所以我认为我无法使用“列表”操作。

【问题讨论】:

  • 看看我对创建 EventGridTrigger 函数订阅者stackoverflow.com/questions/50367435/…的完整endpointUrl 的回答
  • 我实际上遇到了您的答案,但它是使用 REST 调用的解决方案,因此需要一些脚本。我希望有一个纯基于 ARM 的解决方案。

标签: azure azure-functions arm-template azure-eventgrid


【解决方案1】:

是的,现在可以了:

"destination": {
    "endpointType": "WebHook",
    "properties": {
        "endpointUrl": "[concat(variables('functionUrl'), listKeys(resourceId(variables('functionResourceGroupName'), 'Microsoft.Web/sites/host/', variables('functionAppName'), 'default'),'2016-08-01').systemkeys.eventgrid_extension)]"
    }
},

functionUrl&amp;code= 结尾。在运行时 ~2 上进行了测试。

【讨论】:

  • 哦,那太好了,去试试吧!
  • 这仅适用于在模板运行之前已部署该功能的情况。这意味着如果您想在同一部署中使用来自另一个资源的系统密钥,则它不太可能工作。
【解决方案2】:

目前这是不可能的。您只能使用 ARM 模板返回功能键。 这里描述的相同: https://blog.mexia.com.au/list-of-access-keys-from-output-values-after-arm-template-deployment#functions

【讨论】:

  • 我很害怕……在尝试使用 ARM 模板时总是有这些限制:(
猜你喜欢
  • 1970-01-01
  • 2021-10-16
  • 1970-01-01
  • 2019-03-27
  • 2021-03-17
  • 1970-01-01
  • 1970-01-01
  • 2016-06-28
  • 2018-03-25
相关资源
最近更新 更多