Azure Table: Create a Table
See more Azure Table Service Examples
Create a table and request its JSON representation using Prefer: return-content. Requires HTTP 201 and a matching returned TableName; a conflict, redirect, or other unexpected status is not treated as success. This is create-only, not create-if-absent.
Uses Chilkat.Rest and AuthAzureStorage with Table-specific Shared Key signing. Load a private qa_data/azure/storage.json containing string fields account and access_key (the base64 account key, not a connection string or SAS). Keep this file outside public web content and source control. Targets Azure Storage Table service in the public cloud, not Azure Cosmos DB for Table.
Pins x-ms-version: 2026-04-06, Microsoft's documented fully deployed Storage version at review time, and sends OData 3.0 headers. Older supported versions are not automatically obsolete. See Storage versioning and OData headers.
Microsoft recommends Microsoft Entra ID authorization, preferably managed identity where available. This example retains its existing Shared Key authentication pattern; use it only when account policy permits. TLS certificates are verified, timeouts are bounded, and diagnostic dumps and entity payloads are not printed. A lost response can leave a write's outcome uncertain: inspect the target before retrying.
Microsoft create table reference.
Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loTextCompare
LOCAL loConfig
LOCAL lnSameText1
LOCAL lnSameText2
LOCAL loAccountText
LOCAL loAllowedAccountChars
LOCAL lnCharIndex
LOCAL loEndpoint
LOCAL lcResourcePath
LOCAL loRest
LOCAL loAzAuth
LOCAL loConnection
LOCAL loResponseBody
LOCAL lcTableName
LOCAL loJson
LOCAL loRequestBody
LOCAL loResult
LOCAL lnSameText3
lnSuccess = 0
* StringBuilder compares text by value in every generated language.
loTextCompare = CreateObject('Chilkat.StringBuilder')
* Assumes Chilkat is unlocked. See Global Unlock Sample.
lnSuccess = 0
loConfig = CreateObject('Chilkat.JsonObject')
loConfig.Strict = 1
lnSuccess = loConfig.LoadFile("qa_data/azure/storage.json")
IF (lnSuccess <> 1) THEN
? "Could not load private Azure configuration."
RELEASE loTextCompare
RELEASE loConfig
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loConfig.StringOf("account"))
lnSameText1 = loTextCompare.ContentsEqual("",1)
IF ((loConfig.JsonTypeOf("account") <> 1) OR (lnSameText1 = 1)) THEN
? "Supply the storage account name."
RELEASE loTextCompare
RELEASE loConfig
CANCEL
ENDIF
* access_key is the base64 account key, not a connection string or SAS.
loTextCompare.Clear()
loTextCompare.SetString(loConfig.StringOf("access_key"))
lnSameText2 = loTextCompare.ContentsEqual("",1)
IF ((loConfig.JsonTypeOf("access_key") <> 1) OR (lnSameText2 = 1)) THEN
? "Supply the base64 account access key."
RELEASE loTextCompare
RELEASE loConfig
CANCEL
ENDIF
loAccountText = CreateObject('Chilkat.StringBuilder')
lnSuccess = loAccountText.Append(loConfig.StringOf("account"))
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
CANCEL
ENDIF
IF ((loAccountText.Length < 3) OR (loAccountText.Length > 24)) THEN
? "Storage account names need 3-24 lowercase letters or digits."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
CANCEL
ENDIF
loAllowedAccountChars = CreateObject('Chilkat.StringBuilder')
lnSuccess = loAllowedAccountChars.Append("abcdefghijklmnopqrstuvwxyz0123456789")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
CANCEL
ENDIF
lnCharIndex = 0
DO WHILE (lnCharIndex < loAccountText.Length)
IF (loAllowedAccountChars.Contains(loAccountText.GetRange(lnCharIndex,1,0),1) <> 1) THEN
? "Storage account names need lowercase letters or digits."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
CANCEL
ENDIF
lnCharIndex = lnCharIndex + 1
ENDDO
loEndpoint = CreateObject('Chilkat.StringBuilder')
lnSuccess = loEndpoint.Append(loConfig.StringOf("account"))
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
CANCEL
ENDIF
lnSuccess = loEndpoint.Append(".table.core.windows.net")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
CANCEL
ENDIF
* Table names contain only letters and digits and are case-insensitive.
* Entity PartitionKey and RowKey values are case-sensitive.
lcResourcePath = "/Tables"
loRest = CreateObject('Chilkat.Rest')
loRest.ConnectTimeoutMs = 20000
loRest.IdleTimeoutMs = 60000
loAzAuth = CreateObject('Chilkat.AuthAzureStorage')
loAzAuth.Account = loConfig.StringOf("account")
loAzAuth.AccessKey = loConfig.StringOf("access_key")
loAzAuth.Service = "Table"
loAzAuth.Scheme = "SharedKey"
loAzAuth.XMsVersion = "2026-04-06"
lnSuccess = loRest.SetAuthAzureStorage(loAzAuth)
IF (lnSuccess <> 1) THEN
? "Could not configure Shared Key signing."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
CANCEL
ENDIF
loConnection = CreateObject('Chilkat.Socket')
loConnection.RequireSslCertVerify = 1
loConnection.MaxReadIdleMs = 60000
loConnection.MaxSendIdleMs = 60000
lnSuccess = loConnection.Connect(loEndpoint.GetAsString(),443,1,20000)
IF (lnSuccess <> 1) THEN
? "TLS connection failed; inspect diagnostics privately."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
CANCEL
ENDIF
* Do not replay a write automatically after losing its response.
lnSuccess = loRest.UseConnection(loConnection,0)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
CANCEL
ENDIF
loResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loRest.AddHeader("DataServiceVersion","3.0;NetFx")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("MaxDataServiceVersion","3.0;NetFx")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("Content-Type","application/json")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("Accept","application/json;odata=minimalmetadata")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
CANCEL
ENDIF
lnSuccess = loRest.AddHeader("Prefer","return-content")
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
CANCEL
ENDIF
* Table names: 3-63 alphanumeric characters, starting with a letter.
* Replace this literal with your intended table name; do not use the reserved name Tables.
lcTableName = "ExampleCustomers"
loJson = CreateObject('Chilkat.JsonObject')
lnSuccess = loJson.UpdateString("TableName",lcTableName)
IF (lnSuccess <> 1) THEN
? "Could not prepare the request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
CANCEL
ENDIF
loRequestBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loJson.EmitSb(loRequestBody)
IF (lnSuccess <> 1) THEN
? "Could not serialize the JSON request."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
CANCEL
ENDIF
lnSuccess = loRest.FullRequestSb("POST",lcResourcePath,loRequestBody,loResponseBody)
IF (lnSuccess <> 1) THEN
? "Request did not complete; check the target before retrying."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
CANCEL
ENDIF
IF (loRest.ResponseStatusCode <> 201) THEN
? "HTTP status: " + STR(loRest.ResponseStatusCode)
? "Request ID: " + loRest.ResponseHdrByName("x-ms-request-id")
* A conflict is not success. Do not replay or convert this request into an upsert.
IF (loRest.ResponseStatusCode = 409) THEN
? "The table/entity may already exist, or a table may still be deleting. Inspect its state."
ENDIF
* Table errors may be in an OData JSON body instead of x-ms-error-code.
* Keep the body and LastErrorText private; they can contain entity data.
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
CANCEL
ENDIF
loResult = CreateObject('Chilkat.JsonObject')
loResult.Strict = 1
lnSuccess = loResult.LoadSb(loResponseBody)
IF (lnSuccess <> 1) THEN
? "Table created, but its response was not valid JSON. Do not repeat the create blindly."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
RELEASE loResult
CANCEL
ENDIF
loTextCompare.Clear()
loTextCompare.SetString(loResult.StringOf("TableName"))
lnSameText3 = loTextCompare.ContentsEqual(lcTableName,1)
IF ((loResult.JsonTypeOf("TableName") <> 1) OR (lnSameText3 <> 1)) THEN
? "Table created, but the returned TableName did not match. Inspect the target before continuing."
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
RELEASE loResult
CANCEL
ENDIF
? "Created table: " + loResult.StringOf("TableName")
RELEASE loTextCompare
RELEASE loConfig
RELEASE loAccountText
RELEASE loAllowedAccountChars
RELEASE loEndpoint
RELEASE loRest
RELEASE loAzAuth
RELEASE loConnection
RELEASE loResponseBody
RELEASE loJson
RELEASE loRequestBody
RELEASE loResult