Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create Table in Azure Storage Account

Is there's a way to create a Table inside Azure Storage Account using ARM template? I can achieve that using PowerShell but can't find a way to do it using JSON template, also when I browse my deployment resources using (https://resources.azure.com) I can't see any reference to the created table under the storage account, any idea why?

Thanks, A Seyam

like image 206
A Seyam Avatar asked Mar 29 '16 22:03

A Seyam


People also ask

What is Azure storage account tables?

Azure Table storage is a cloud-based NoSQL datastore you can use to store large amounts of structured, non-relational data. Azure Table offers a schemaless design, which enables you to store a collection of entities in one table. An entity contains a set of properties, and each property defines a name-value pair.


2 Answers

You can create an Azure Storage account with a table via ARM like this, using a tableServices/tables sub-resource on your storageAccount resource:

{
  "$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'))]"
          ]
        }
      ]
    }
  ]
}

The functionality is documented on the ARM Template spec page for tableServices/tables.

like image 90
c-w Avatar answered Oct 13 '22 13:10

c-w


  1. As far as I know, no. You could look at Get started with Azure Table storage using .NET/PHP/Python/... for details.
  2. The Table service exposes Account, Tables, Entity via the REST API, so you couldn't see them in the portal. You can check out Addressing Table Service Resources for more info.
like image 30
Steven Avatar answered Oct 13 '22 13:10

Steven