代码之家  ›  专栏  ›  技术社区  ›  David Gard

通过arm创建到azure表存储的api连接

  •  2
  • David Gard  · 技术社区  · 6 年前

    我正试图通过arm模板将api连接部署到表存储,但是下面的模板返回一个错误-

    输入参数无效。有关详细信息,请参见详细信息。详细信息:错误代码:parameterNotDefined。消息:不允许在连接上使用参数“accountkey”,因为在注册api时,该参数未定义为连接参数。

    我找不到任何特定于通过arm部署这样一个api连接的文档,只有 generic ARM template docs 没有任何例子 parameterValues 使用,和 Table Store connection docs 似乎是针对rest api的,没有指定 parameterVaules 用于ARM部署。

    有谁能告诉我 参数值 使用?

    {
        "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "connectionName": {
                "type": "string",
                "defaultValue": "azuretablestest",
                "metadata": {
                    "description": "The name of the connection to the Table Store that the Logic App will use."
                }
            },
            "connectionDisplayName": {
                "type": "string",
                "defaultValue": "AzureTablesTest",
                "metadata": {
                    "description": "The display name of the connection to the Table Store that the Logic App will use."
                }
            },
            "locationName": {
                "type": "string",
                "defaultValue": "UK South",
                "metadata": {
                    "description": "The Azure location to use when creating resources (eg. North Europe)."
                }
            }
        },
        "variables": {},
        "resources": [
            {
                "comments": "Connection to the Table Store that will hold HMLR Business Gateway Service responses.",
                "type": "Microsoft.Web/connections",
                "name": "[parameters('connectionName')]",
                "apiVersion": "2016-06-01",
                "location": "[parameters('locationName')]",
                "scale": null,
                "properties": {
                    "displayName": "[parameters('connectionDisplayName')]",
                    "customParameterValues": {},
                    "parameterValues": {
                        "accountName": "mystorageaccount",
                        "accessKey": "**********",
                        "tableName": "myTableName"
                    },
                    "api": {
                        "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', replace(toLower(parameters('locationName')), ' ', ''), '/managedApis/azuretables')]"
                    }
                },
                "dependsOn": []
            }
        ]
    }
    
    2 回复  |  直到 6 年前
        1
  •  5
  •   Tom Sun    6 年前

    参数值应如下所示:

    "parameterValues": {
              "storageaccount": "storageAccount",
              "sharedkey": "accountKey"
            }
    

    以及 "tableName" 不允许在 parameterValues 是的。

    我用下面的ARM模板测试它,它对我来说是正确的。如果不想将硬代码与存储帐户密钥一起使用,可以使用 ListKeys 在ARM模板中的函数。

    {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "connectionName": {
          "type": "string",
          "defaultValue": "azuretablestest",
          "metadata": {
            "description": "The name of the connection to the Table Store that the Logic App will use."
          }
        },
        "connectionDisplayName": {
          "type": "string",
          "defaultValue": "AzureTablesTest",
          "metadata": {
            "description": "The display name of the connection to the Table Store that the Logic App will use."
          }
        },
        "locationName": {
          "type": "string",
          "defaultValue": "eastus",
          "metadata": {
            "description": "The Azure location to use when creating resources (eg. North Europe)."
          }
        }
      },
      "variables": {},
      "resources": [
        {
          "comments": "Connection to the Table Store that will hold HMLR Business Gateway Service responses.",
          "type": "Microsoft.Web/connections",
          "name": "[parameters('connectionName')]",
          "apiVersion": "2016-06-01",
          "location": "[parameters('locationName')]",
          "scale": null,
          "properties": {
            "displayName": "[parameters('connectionDisplayName')]",
            "customParameterValues": {},
            "parameterValues": {
              "storageaccount": "accountName",
              "sharedkey": "accountKey"
            },
            "api": {
              "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', replace(toLower(parameters('locationName')), ' ', ''), '/managedApis/azuretables')]"
            }
          },
          "dependsOn": []
        }
      ],
      "outputs": {}
    }
    
        2
  •  0
  •   illremember thistime    6 年前

    接受的答案上的值对我不起作用,但是:

    "parameterValues": {
              "accountName": "[parameters('storageName')]",
              "accessKey": "[parameters('storageKey')]"
            }