6

有没有办法使用 ARM 模板在 Azure 存储帐户中创建表?我可以使用 PowerShell 实现这一点,但找不到使用 JSON 模板的方法,当我使用 ( https://resources.azure.com ) 浏览我的部署资源时,我看不到对创建表的任何引用在存储帐户下,知道为什么吗?

谢谢, 一个 Seyam

4

3 回答 3

4

tableServices/tables您可以像这样通过 ARM 使用资源上的子资源创建带有表的 Azure 存储帐户storageAccount

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccountName": {
      "type": "string",
      "minLength": 3,
      "maxLength": 24
    },
    "storageAccountSku": {
      "type": "string",
      "defaultValue": "Standard_LRS",
      "allowedValues": [
        "Standard_LRS",
        "Standard_GRS",
        "Standard_RAGRS"
      ]
    },
    "tableName": {
      "type": "string",
      "minLength": 3,
      "maxLength": 63
    }
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[parameters('storageAccountName')]",
      "apiVersion": "2019-06-01",
      "location": "[resourceGroup().location]",
      "kind": "StorageV2",
      "sku": {
        "name": "[parameters('storageAccountSku')]"
      },
      "resources": [
        {
          "name": "[concat('default/', parameters('tableName'))]",
          "type": "tableServices/tables",
          "apiVersion": "2019-06-01",
          "dependsOn": [
            "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
          ]
        }
      ]
    }
  ]
}

该功能记录在tableServices/tables 的 ARM 模板规范页面上

于 2020-07-10T17:58:13.423 回答
3
  1. 据我所知,没有。您可以查看使用 .NET/PHP/Python/... 开始使用 Azure 表存储以了解详细信息。
  2. 表服务通过 REST API 公开帐户、表、实体,因此您无法在门户中看到它们。您可以查看寻址表服务资源以获取更多信息。
于 2016-03-30T02:17:58.260 回答
-1

通过一些简单的步骤使用 ARM 模板创建 Azure 存储。请找到以下步骤来实施它。

第 1 步:打开您的 powershell 并使用以下命令登录您的帐户Connect-AzureRmAccount

第 2 步:添加您的 SubscriptionId Select-AzureRmSubscription -SubscriptionId <your SubscriptionId>

步骤 3:创建资源组New-AzureRmResourceGroup -Name yourResourceGroup -Location "South Central US"

第 4 步:创建 azuredeploy.json 和 azuredeploy.parameters.json

天蓝色部署.json

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "storageAccountName": {
        "type": "string",
        "metadata": {
            "description": "The name of the Azure Storage account."
        }
    },
    "containerName": {
        "type": "string",
        "defaultValue": "logs",
        "metadata": {
            "description": "The name of the blob container."
        }
    },
    "location": {
        "type": "string",
        "defaultValue": "[resourceGroup().location]",
        "metadata": {
            "description": "The location in which the Azure Storage resources should be deployed."
        }
    }
},
"resources": [
    {
        "name": "[parameters('storageAccountName')]",
        "type": "Microsoft.Storage/storageAccounts",
        "apiVersion": "2018-02-01",
        "location": "[parameters('location')]",
        "kind": "StorageV2",
        "sku": {
            "name": "Standard_LRS",
            "tier": "Standard"
        },
        "properties": {
            "accessTier": "Hot"
        },
        "resources": [
            {
                "name": "[concat('default/', parameters('containerName'))]",
                "type": "blobServices/containers",
                "apiVersion": "2018-03-01-preview",
                "dependsOn": [
                    "[parameters('storageAccountName')]"
                ]
            }
        ]
    }
]
}

azuredeploy.parameters.json

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "storageAccountName": {
        "value": "yourstorage"
    }
}
}

第五步:运行以下命令

New-AzureRmResourceGroupDeployment -Name myDeployment -ResourceGroupName yourResourceGroup -TemplateFile <location>\azuredeploy.json -TemplateParameterFile <location>\azuredeploy.parameters.json

第 6 步:

$saContext = (Get-AzureRmStorageAccount -ResourceGroupName yourResourceGroup -Name sitastoragee).Context 
New-AzureStorageTable –Name yourtablestorage –Context $saContext
于 2018-09-05T12:39:38.353 回答