Azure ARM模板-获取函数的特定主机密钥

Azure ARM模板-获取函数的特定主机密钥,azure,arm-template,Azure,Arm Template,我必须为我的Azure函数创建一个主机密钥(在API管理后端中使用),并通过参数传入一个名称。 我不知道如何使用listKeys按名称获取一个特定的主机键 我像这样创建主机密钥,如果我不添加输出,这将正常工作 { "type": "Microsoft.Web/sites/host/functionKeys", "apiVersion&q

我必须为我的Azure函数创建一个主机密钥(在API管理后端中使用),并通过参数传入一个名称。 我不知道如何使用listKeys按名称获取一个特定的主机键

我像这样创建主机密钥,如果我不添加输出,这将正常工作

{
                            "type": "Microsoft.Web/sites/host/functionKeys",
                            "apiVersion": "2018-11-01",
                            "name": "[concat(variables('functionSite-name'), '/default/',variables('apim-name'))]",
                            "properties": {
                                "name": "[variables('apim-name')]"
                            }
                        }
我尝试了这个,从另一篇文章中获得了它,但它返回了错误: {“代码”:“DeploymentFailed”,“消息”:“至少一个资源部署操作失败。有关详细信息,请列出部署操作。有关用法详细信息,请参阅。”,“详细信息”:[{“代码”:“InvalidResourceNamespace”,“消息”:“资源命名空间“GetVersionPocapeManagement”无效。”}]}

“functionSite name”是我的Azure功能的名称(Microsoft.Web/sites) “apim名称”是创建的主机密钥的名称(Microsoft.Web/sites/host/functionKeys)

作为我完整脚本的参考,我使用部署,因为我的Azure功能位于另一个资源组中,我需要创建主机密钥,然后将其添加到密钥库。之后,我必须配置API管理实例以使用此Azure函数

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
    },
    "variables": {
        "apim-name": "eud-sse-poc-apim",
        "api-name": "GetVersionPOCApiManagement",
        "functionSite-name": "GetVersionPOCApiManagement",
        "functionSite-ResourceGroup": "eud-sse-poc-datafactory-rg"
    },
    "resources": [
        {
            "type": "Microsoft.Resources/deployments",
            "apiVersion": "2020-10-01",
            "name": "azureFunctionDeployments",
            "resourceGroup": "[variables('functionSite-ResourceGroup')]",
            "properties": {
                "mode": "Incremental",
                "template": {
                    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                    "contentVersion": "1.0.0.0",
                    "resources": [
                        {
                            "type": "Microsoft.Web/sites/host/functionKeys",
                            "apiVersion": "2018-11-01",
                            "name": "[concat(variables('functionSite-name'), '/default/',variables('apim-name'))]",
                            "properties": {
                                "name": "[variables('apim-name')]"
                            }
                        }
                    ],
                    "outputs": {
                        "hostKey": {                            
                            "type": "string",
                            "value": "[listkeys(concat(variables('functionSite-name'), '/host/default/'),'2016-08-01').functionKeys[variables('apim-name')]]"
                        }
                    }
                }
            }
        }



    ],
    "outputs": {}
}

有什么建议吗?

我自己找到的,看错了地方

[listkeys(concat(variables('functionSite-name'), '/host/default/'),'2016-08-01').functionKeys[variables('apim-name')]]
应该是

[listKeys(concat(resourceId(variables('functionSite-ResourceGroup'),'Microsoft.Web/sites', 'GetVersionPOCApiManagement'), '/host/default'), '2016-08-01').functionKeys[variables('apim-name')]]
因此,我可以确认您可以在ARM模板中访问StringDictionary

[listKeys(concat(resourceId(variables('functionSite-ResourceGroup'),'Microsoft.Web/sites', 'GetVersionPOCApiManagement'), '/host/default'), '2016-08-01').functionKeys[variables('apim-name')]]