Performing simple Azure Table Storage REST API operations using curl command. by info.odysseyx@gmail.com August 23, 2024 written by info.odysseyx@gmail.com August 23, 2024 0 comment 7 views 7 This blog provides instructions on how to perform simple Table storage REST API operations such as create table, drop table, insert entity, delete entity, merge entity, get table properties, get table store statistics, query table, query entity, and update entity operations using curl commands. We will look at some command syntax for performing REST API operations and will use SAS token as an authentication mechanism. You will need to take care of the pointers below while performing the operations via curl command. Make sure the URL is correctly structured for the task you are trying to perform. Required headers must be passed with correct values. You need to add or remove unnecessary ‘?’ from SAS tokens in your URL. The HTTP verb can be GET, PUT or DELETE, depending on the REST API specification. So, shall we begin? Get table storage properties: This Rest API gets the properties of an Azure Table Storage account. Here is the reference link for the Rest API. Get Table Service Properties (REST API) – Azure Storage | Microsoft LearnSyntax URL: curl -X GET "https://.table.core.windows.net/?restype=service&comp=properties" -H "x-ms-date:2024-02-23T03:24Z" -H "x-ms-version:2020-04-08" calculation: Get table storage statistics: This Rest API retrieves statistics related to replication in Azure Table Storage. This operation only works on: 2nd location end point If RAGRS replication is enabled for the storage account. Reference links: Get Table Service Statistics (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X GET "https://storageaccount-secondary.table.core.windows.net/?restype=service&comp=stats&” -H "x-ms-date:2024-02-23T03:24Z" -H "x-ms-version:2020-04-08" calculation: question table: This Rest API returns a list of tables under a specified account. Reference Link: Query Tables (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X GET "https://storageaccount.table.core.windows.net/Tables?" -H "x-ms-date:2024-02-23T18:16:35Z" -H "x-ms-version:2020-04-08" calculation: Create a table: This Rest API creates a new table in a storage account. Reference links: Create Table (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X POST "https://storageaccount.table.core.windows.net/Tables? " -H "x-ms-date:2024-02-23T18:16:35Z" -H "x-ms-version:2020-04-08" -H "Content-Length: 27" -H "Content-Type: application/json" -d "{\"TableName\":\"sampletable\"} calculation: Delete table: This Rest API deletes a table from a storage account. Reference links: Delete Table (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X DELETE "https://storageaccount.table.core.windows.net/Tables('sampletable')? " -H "x-ms-date:2024-02-23T18:16:35Z" -H "x-ms-version:2020-04-08" -H "Content-Type: application/json" calculation: Entity query:This Rest API queries entities in a table and includes $filter and $select options. Reference links: Entity Query (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X GET "https://storageaccount.table.core.windows.net/shswadsampletable1(PartitionKey='B',RowKey='1')? " -H "x-ms-date:2024-02-24T10:14:50.2646880Z" -H "x-ms-version:2020-04-08" calculation: Delete entity operation:This Rest API deletes an existing entity in a table. Reference link: Delete Entity (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X DELETE "https://storageaccount.table.core.windows.net/shswadsampletable1(PartitionKey%3D'B'%2C%20RowKey%3D'1')? " -H "x-ms-date:2024-02-24T11:14:50.2646880Z" -H "x-ms-version:2020-04-08" -H "If-Match:*" calculation: Insert operation: This Rest API inserts a new entity into a table. Reference links: Insert Entity (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X POST "https://storageaccount.table.core.windows.net/test? " -H "x-ms-date: 2024-02-25T10:39:50.2646880Z" -H "x-ms-version: 2020-04-08" -H "Accept: application/json;odata=nometadata" -H "Content-Type: application/json" -d "{\"RowKey\":\"bbb\",\"PartitionKey\":\"ssss\",\"Name\":\"aaa\",\"PhoneNumber\":\"111\"}" calculation: Update task: This Rest API updates an existing entity in Table Storage. Reference Links: Update Entity (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X PUT "https://storageaccount.table.core.windows.net/test(PartitionKey%3D'ss'%2C%20RowKey%3D'bbb')? " -H "x-ms-date: 2024-02-25T10:39:50.2646880Z" -H "x-ms-version: 2020-04-08" -H "Accept: application/json;odata=nometadata" -H "Content-Type: application/json" -H "If-Match=*" -d "{\"RowKey\":\"bbb\",\"PartitionKey\":\"ssss\",\"Name\":\"aaa\",\"PhoneNumber\":\"111\"} calculation Merge operation:This Rest API operation updates an existing entity by updating the properties of the entity and does not replace the existing entity. Reference links: Merge Entities (REST API) – Azure Storage | Microsoft Learn Syntax URL: curl -X PUT "https://storageaccount.table.core.windows.net/test(PartitionKey%3D'ssss'%2C%20RowKey%3D'bbb')? " -H "x-ms-version: 2020-04-08" -H "Accept: application/json;odata=nometadata" -H "Content-Type: application/json" -H "If-Match=*" -d "{\"RowKey\":\"bbb\",\"PartitionKey\":\"ssss\",\"Name\":\"aaa\",\"PhoneNumber\":\"11231\"}" calculation: I hope this article will help you perform table save operations using the curl command. Have fun learning! Source link Share 0 FacebookTwitterPinterestEmail info.odysseyx@gmail.com previous post California Consumer Privacy Act (CCPA) Opt-Out Icon next post Implementing Data Vault 2.0 on Fabric Data Warehouse You may also like From Zero to Hero: Building Your First Voice Bot with GPT-4o Real-Time API using... October 12, 2024 A Guide to Responsible Synthetic Data Creation October 12, 2024 Capacity Template – MGDC for SharePoint October 11, 2024 Using Azure NetApp Files (ANF) for data- and logfiles for Microsoft SQL Server in... October 11, 2024 Microsoft Community – Do you love stickers?! Do you want to be a part... October 11, 2024 Advanced Alerting Strategies for Azure Monitoring October 11, 2024 Leave a Comment Cancel Reply Save my name, email, and website in this browser for the next time I comment.