Create an API Connection to an Azure Table Store via ARM

試著忘記壹切 提交于 2019-12-20 03:01:13

问题


I'm attempting to deploy an API Connection to a Table Store via an ARM template, but the template below is returning an error -

Input parameters are invalid. See details for more information. Details:errorCode: ParameterNotDefined. Message: Parameter 'accountKey' is not allowed on the connection since it was not defined as a connection parameter when the API was registered.

I cannot find any docs specific to deploying such an API Connection via ARM, only generic ARM template docs which don't give any examples of which parameterValues to use, and Table Store connection docs which seem to be aimed towards the REST API and don't specify the parameterVaules required for ARM deployments.

Is anyone able to tell me which parameterValues to use?

{
    "$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": []
        }
    ]
}

回答1:


The parameterValues should be as following:

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

And "tableName" is not allowed in the parameterValues.

I test it with following ARM template, it works correctly for me. If you don't want to using hard code with storage account key, you could use the ListKeys function in the ARM template.

{
  "$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:


The values on the accepted answer did not work for me, this did though:

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


来源:https://stackoverflow.com/questions/51288990/create-an-api-connection-to-an-azure-table-store-via-arm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!