首页 > 解决方案 > Azure 搜索、listAdminKeys、ARM 输出错误(不支持 http 方法 'POST')

问题描述

我在我的 ARM 模板中使用这段代码作为输出对象,

    "[listAdminKeys(variables('searchServiceId'), '2015-08-19').PrimaryKey]"

输出部分的全文示例:

    "outputs": {
     "SearchServiceAdminKey": {
       "type": "string",
       "value": "[listAdminKeys(variables('searchServiceId'), '2015-08-19').PrimaryKey]"
      },

     "SearchServiceQueryKey": {
       "type": "string",
       "value": "[listQueryKeys(variables('searchServiceId'), '2015-08-19')[0]]"
      }

我在部署期间收到以下错误(不幸的是,任何错误都意味着模板部署跳过了输出部分):

    "The requested resource does not support http method 'POST'."

检查浏览器行为似乎可以验证错误与函数有关(并且,它使用 POST)。

listAdminKeys 使用 POST

如何避免此错误并在输出中检索 AzureSearch 管理密钥?

更新:这样做的目的是收集所有相关信息以作为参数插入其他脚本 (.ps1),因为这些资源是由该模板提供的。将避免有人通过门户挖掘复制/粘贴。

谢谢

标签: azureazure-resource-managerazure-cognitive-searcharm-template

解决方案


您的错误来自 listQueryKeys,而不是管理键。

https://docs.microsoft.com/en-us/rest/api/searchmanagement/adminkeys/get
https://docs.microsoft.com/en-us/rest/api/searchmanagement/querykeys/listbysearchservice

您将无法检索 arm 模板中的那些,它只能“模拟” POST 调用,而不是 GET


推荐阅读