Sample code for 30+ languages & platforms
AutoIt Requires Chilkat v11.6.0+

Azure Table: Insert an Entity with Typed Properties

See more Azure Table Service Examples

Insert into an existing table using Prefer: return-no-content. Requires HTTP 204, avoids parsing its empty body, and captures the ETag for later conditional writes. Insert is create-only; an existing PartitionKey/RowKey pair produces a conflict.

Includes explicit Edm.Guid, Edm.DateTime, and Edm.Int64 annotations. The Int64 is serialized as a string beyond JavaScript's exact integer range, preserving its digits in every generated language. The timestamp is server-managed. AmountDue demonstrates Edm.Double, which is not exact decimal currency. See Table JSON types.

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 insert entity reference.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  StringBuilder compares text by value in every generated language.
$oTextCompare = ObjCreate("Chilkat.StringBuilder")
;  Assumes Chilkat is unlocked. See Global Unlock Sample.
$bSuccess = False
$oConfig = ObjCreate("Chilkat.JsonObject")
$oConfig.Strict = True
$bSuccess = $oConfig.LoadFile("qa_data/azure/storage.json")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not load private Azure configuration." & @CRLF)
    Exit
EndIf

$oTextCompare.Clear 
$oTextCompare.SetString($oConfig.StringOf("account"))
Local $bSameText1 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("account") <> 1) Or ($bSameText1 = True)) Then
    ConsoleWrite("Supply the storage account name." & @CRLF)
    Exit
EndIf

;  access_key is the base64 account key, not a connection string or SAS.
$oTextCompare.Clear 
$oTextCompare.SetString($oConfig.StringOf("access_key"))
Local $bSameText2 = $oTextCompare.ContentsEqual("",True)
If (($oConfig.JsonTypeOf("access_key") <> 1) Or ($bSameText2 = True)) Then
    ConsoleWrite("Supply the base64 account access key." & @CRLF)
    Exit
EndIf

$oAccountText = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oAccountText.Append($oConfig.StringOf("account"))
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

If (($oAccountText.Length < 3) Or ($oAccountText.Length > 24)) Then
    ConsoleWrite("Storage account names need 3-24 lowercase letters or digits." & @CRLF)
    Exit
EndIf

$oAllowedAccountChars = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oAllowedAccountChars.Append("abcdefghijklmnopqrstuvwxyz0123456789")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

Local $iCharIndex = 0
While ($iCharIndex < $oAccountText.Length)
    If ($oAllowedAccountChars.Contains($oAccountText.GetRange($iCharIndex,1,False),True) <> True) Then
        ConsoleWrite("Storage account names need lowercase letters or digits." & @CRLF)
        Exit
    EndIf

    $iCharIndex = $iCharIndex + 1
Wend
$oEndpoint = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oEndpoint.Append($oConfig.StringOf("account"))
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oEndpoint.Append(".table.core.windows.net")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  Table names contain only letters and digits and are case-insensitive.
;  Entity PartitionKey and RowKey values are case-sensitive.
Local $sResourcePath = "/ExampleCustomers"
$oRest = ObjCreate("Chilkat.Rest")
$oRest.ConnectTimeoutMs = 20000
$oRest.IdleTimeoutMs = 60000
$oAzAuth = ObjCreate("Chilkat.AuthAzureStorage")
$oAzAuth.Account = $oConfig.StringOf("account")
$oAzAuth.AccessKey = $oConfig.StringOf("access_key")
$oAzAuth.Service = "Table"
$oAzAuth.Scheme = "SharedKey"
$oAzAuth.XMsVersion = "2026-04-06"
$bSuccess = $oRest.SetAuthAzureStorage($oAzAuth)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not configure Shared Key signing." & @CRLF)
    Exit
EndIf

$oConnection = ObjCreate("Chilkat.Socket")
$oConnection.RequireSslCertVerify = True
$oConnection.MaxReadIdleMs = 60000
$oConnection.MaxSendIdleMs = 60000
$bSuccess = $oConnection.Connect($oEndpoint.GetAsString(),443,True,20000)
If ($bSuccess <> True) Then
    ConsoleWrite("TLS connection failed; inspect diagnostics privately." & @CRLF)
    Exit
EndIf

;  Do not replay a write automatically after losing its response.
$bSuccess = $oRest.UseConnection($oConnection,False)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$oResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oRest.AddHeader("DataServiceVersion","3.0;NetFx")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oRest.AddHeader("MaxDataServiceVersion","3.0;NetFx")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oRest.AddHeader("Content-Type","application/json")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oRest.AddHeader("Accept","application/json;odata=minimalmetadata")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oRest.AddHeader("Prefer","return-no-content")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  The table must already exist. Change resourcePath above to your table's name.
;  PartitionKey + RowKey uniquely identify the entity. Inserting an existing pair returns 409.
;  Adapt these fixed sample values; keys cannot contain /, backslash, #, ?, or control characters.
;  Timestamp is server-managed; do not put it in the request.
$oJson = ObjCreate("Chilkat.JsonObject")
$bSuccess = $oJson.UpdateString("PartitionKey","customers-west")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateString("RowKey","customer-001")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateString("Address","Mountain View")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateInt("Age",23)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateNumber("AmountDue","200.23")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  AmountDue is Edm.Double, not exact decimal currency. Use an integer minor-unit design for exact money.
;  Quote the whole JSON path so @odata.type is a literal property name.
$bSuccess = $oJson.UpdateString("""CustomerCode@odata.type""","Edm.Guid")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateString("CustomerCode","c9da6455-213d-42c9-9a79-3e9149a57833")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  Quote the whole JSON path so @odata.type is a literal property name.
$bSuccess = $oJson.UpdateString("""CustomerSince@odata.type""","Edm.DateTime")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateString("CustomerSince","2008-07-10T00:00:00Z")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

;  Quote the whole JSON path so @odata.type is a literal property name.
$bSuccess = $oJson.UpdateString("""NumberOfOrders@odata.type""","Edm.Int64")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateString("NumberOfOrders","9007199254740993")
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$bSuccess = $oJson.UpdateBool("IsActive",True)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not prepare the request." & @CRLF)
    Exit
EndIf

$oRequestBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oJson.EmitSb($oRequestBody)
If ($bSuccess <> True) Then
    ConsoleWrite("Could not serialize the JSON request." & @CRLF)
    Exit
EndIf

$bSuccess = $oRest.FullRequestSb("POST",$sResourcePath,$oRequestBody,$oResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite("Request did not complete; check the target before retrying." & @CRLF)
    Exit
EndIf

If ($oRest.ResponseStatusCode <> 204) Then
    ConsoleWrite("HTTP status: " & $oRest.ResponseStatusCode & @CRLF)
    ConsoleWrite("Request ID: " & $oRest.ResponseHdrByName("x-ms-request-id") & @CRLF)
    ;  A conflict is not success. Do not replay or convert this request into an upsert.
    If ($oRest.ResponseStatusCode = 409) Then
        ConsoleWrite("The table/entity may already exist, or a table may still be deleting. Inspect its state." & @CRLF)
    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.
    Exit
EndIf

;  HTTP 204 has no JSON body. Preserve this ETag exactly, including W/ and quotes,
;  for a later conditional update or delete with If-Match.
Local $sEntityEtag = $oRest.ResponseHdrByName("ETag")
$oTextCompare.Clear 
$oTextCompare.SetString($sEntityEtag)
Local $bSameText3 = $oTextCompare.ContentsEqual("",True)
If ($bSameText3 = True) Then
    ConsoleWrite("Entity inserted, but ETag is missing. Retrieve the entity before a conditional write; do not repeat the insert." & @CRLF)
    Exit
EndIf

ConsoleWrite("Entity inserted." & @CRLF)
ConsoleWrite("ETag: " & $sEntityEtag & @CRLF)