Azure blob storage service allows HTTP operations on resources using REST APIs. It exposes storage account, containers & blobs via the REST API. You can address each resource using its resource URI. Each resource supports operations based on the HTTP verbs GET, PUT and DELETE. You can find step by step explanation on how to achieve this.
Create Storage Account: Follow the steps to create Azure Storage Account with REST API using Postman
Container:
Create Container:
>>Open Postman and create a collection and add a request to authenticate azure service principal with client secret using postman.
>>Add another PUT request as shown below
PUT request is as shown below. The values for storage account name {account Name} and container name {containerName} to be created is populated from environment variable values-
https://{{accountName}}.blob.core.windows.net/{{containerName}}?restype=container
Similarly the Authorization Type “Bearer Token” gets its value from environment variable {currentAccessToken} [Note: this variable name should be the one you used to save the access token in authentication request for service principal]
>>Add Header parameter – Content-Type, x-ms-version, x-ms-blob-public-access (this parameter value define whether the container is private or public) [Note: Check this link for more details on parameters which can be passed in request]
>>Save and Send the request. It will return status code “201 Created” if it is successful.
Create Blob in Container
>> Add another PUT request as shown below to upload any log file, image etc. Make sure that the service principal is assigned “Storage Blob Data Contributor” role for this operation.
PUT request is as shown below. The values for storage account name {account Name} and container name {containerName} to be created is populated from environment variable values, {blob_name} is name of the file which you want to upload to container-
https://{{accountName}}.blob.core.windows.net/{{containerName}}/{{blob_name}}
Similarly the Authorization Type “Bearer Token” gets its value from environment variable {currentAccessToken} [Note: this variable name should be the one you used to save the access token in authentication request for service principal]
>>Add Header required parameters – x-ms-version, x-ms-blob-type (this parameter value define whether the blob is block or page or append) [Note: Check this link for more details on parameters which can be passed in request]
>>Save and Send the request. It will return status code “201 Created” if it is successful.