如何使用 ARM 模板为注释创建 Application Insights API 密钥

hon*_*onk 2 azure azure-resource-manager azure-application-insights azure-rm-template

我正在尝试从 ARM 模板创建 Application Insights API 密钥。我需要在资源部署期间创建用于写入注释的 API 密钥,以便在从 Azure Devops 部署应用程序期间使发布注释正常工作。

我尝试查找有关如何实现此功能的信息,但我只能找到有关如何使用 PowerShell 或 Azure REST API 创建密钥的示例。

我需要开始工作的是使用 ARM 模板创建 API 密钥。我已经尝试了很多与此类似的 json 尝试,但没有成功;

 {
  "name": "[variables('applicationInsightsName')]",
  "type": "Microsoft.Insights/components",
  "location": "[resourceGroup().location]",
  "apiVersion": "2014-04-01",
  "tags": {
    "displayName": "[concat('Component ', variables('applicationInsightsName'))]"
  },
  "properties": {
    "applicationId": "[variables('applicationInsightsName')]"
  },
  "resources": [
    {
      "name": "action",
      "type": "apikeys",
      "location": "[resourceGroup().location]",
      "apiVersion": "2015-05-01",
      "properties": {
        "name": "Azure Devops Release Annotations",
        "linkedWriteProperties": [
          "[concat(resourceId('Microsoft.Insights/components', variables('applicationName')), '/annotations')]"
        ],
        "linkedReadProperties": []
      },
      "dependsOn": [
        "[resourceId('Microsoft.Insights/components', variables('applicationInsightsName'))]"
      ]
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

到目前为止我找到的最好的信息是 这个,但没有太大帮助。

是否可以使用 ARM 模板创建 API 密钥?

4c7*_*b41 5

不,这是不可能的,ARM 模板仅模拟PUT请求,而这Microsoft.Insights/Components/ApiKeys/Action是一个POST请求。