The REST API for the Azure NetApp Files service defines HTTP operations against resources such as the NetApp account, the capacity pool, the volumes, and snapshots. This article helps you get started with using the Azure NetApp Files REST API.
Azure NetApp Files REST API specification
The REST API specification for Azure NetApp Files is published through GitHub:
When the API limit has been exceeded, the HTTP response code is 429. For example:
"Microsoft.Azure.ResourceProvider.Common.Exceptions.ResourceProviderException: Error getting Pool. Rate limit exceeded for this endpoint - try again later ---> CloudVolumes.Service.Client.Client.ApiException: Error calling V2DescribePool: {\"code\":429,\"message\":\"Rate limit exceeded for this endpoint - try again later\"}
Keep the command output. You will need the appId, password, and tenant values.
Request an OAuth access token:
The examples in this article use cURL. You can also use various API tools such as Postman, Insomnia, and Paw.
Replace the variables in the following example with the command output from Step 2 above.
Azure CLI
curl -X POST -d'grant_type=client_credentials&client_id=[APP_ID]&client_secret=[PASSWORD]&resource=https%3A%2F%2Fmanagement.azure.com%2F' https://login.microsoftonline.com/[TENANT_ID]/oauth2/token
The output provides an access token similar to the following example:
The displayed token is valid for 3600 seconds. After that, you need to request a new token.
Save the token to a text editor. You will need it for the next step.
Send a test call and include the token to validate your access to the REST API:
Azure CLI
curl -X GET -H"Authorization: Bearer [TOKEN]"-H"Content-Type: application/json" https://management.azure.com/subscriptions/[SUBSCRIPTION_ID]/providers/Microsoft.Web/sites?api-version=2022-05-01
Examples using the API
This article uses the following URL for the baseline of requests. This URL points to the root of the Azure NetApp Files namespace.
#get capacity pools for NetApp account
curl -X GET -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools?api-version=2022-05-01
Azure CLI
#get volumes in NetApp account & capacity pool
curl -X GET -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools/CAPACITYPOOLGOESHERE/volumes?api-version=2022-05-01
Azure CLI
#get snapshots for a volume
curl -X GET -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools/CAPACITYPOOLGOESHERE/volumes/VOLUMEGOESHERE/snapshots?api-version=2022-05-01
PUT request examples
You use a PUT request to create new objects in Azure NetApp Files, as the following examples show. The body of the PUT request can include the JSON formatted data for the changes. It must be included in the curl command as text or references as a file. To reference the body as a file, save the json example to a file and add -d @<filename> to the curl command.
Azure CLI
#create a NetApp account
curl -d @<filename>-X PUT -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE?api-version=2022-05-01
Azure CLI
#create a capacity pool
curl -d @<filename>-X PUT -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools/CAPACITYPOOLGOESHERE?api-version=2022-05-01
Azure CLI
#create a volume
curl -d @<filename>-X PUT -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools/CAPACITYPOOLGOESHERE/volumes/MYNEWVOLUME?api-version=2022-05-01
Azure CLI
#create a volume snapshot
curl -d @<filename>-X PUT -H"Authorization: Bearer TOKENGOESHERE"-H"Content-Type: application/json" https://management.azure.com/subscriptions/SUBIDGOESHERE/resourceGroups/RESOURCEGROUPGOESHERE/providers/Microsoft.NetApp/netAppAccounts/NETAPPACCOUNTGOESHERE/capacityPools/CAPACITYPOOLGOESHERE/volumes/MYNEWVOLUME/Snapshots/SNAPNAME?api-version=2022-05-01
JSON examples
The following example shows how to create a NetApp account:
Tìm hiểu về các phần chính của Azure NetApp Files, bao gồm thuật ngữ lưu trữ và chiến lược giám sát, để giúp bạn tối ưu hóa quy trình thiết lập và triển khai của mình.
Xây dựng các giải pháp toàn năng trong Microsoft Azure để tạo Azure Functions, triển khai và quản lý các ứng dụng web, phát triển các giải pháp sử dụng bộ nhớ Azure và hơn thế nữa.