NetApp Backup and Recovery™ protects your ONTAP volumes, Kubernetes applications, and virtual machine workloads by sending backup copies to object storage. Before you can pick a bucket or container as a backup destination, Backup and Recovery needs credentials to access the object store: a service principal for Azure Blob, an access key pair for Amazon Web Services (AWS) S3, or an S3 user for ONTAP® S3.
Most people add these credentials once through the NetApp Console™ UI. That is fine for a first proof of concept. As soon as your environment grows, the manual approach shows its limits:
- Repeatability: Clicking through the same wizard for every account, region, or lab is slow and error prone. A script produces the same result every time.
- Automation and infrastructure as code: Provisioning a new environment often includes creating storage, setting up credentials, and configuring data protection. If one of these steps needs the UI, you cannot fully automate the pipeline.
- Scale: Service providers and large enterprises manage many accounts and object stores. The API lets you loop over them instead of repeating manual steps.
- Auditability: Scripts live in version control, so you can review, share, and reuse them.
The Console exposes these tasks through REST APIs. In this post, we walk through the complete flow: how to set up authentication, how to collect the identifiers the API calls require, and how to add credentials for each of the three external backup destinations. Each step includes a curl example you can adapt to your own environment.
Prerequisites
Before you start, make sure you have the following:
- A NetApp Console account with access to Backup and Recovery, and a Console agent installed in your environment. The agent must be associated with a project (called a workspace in the API).
- A Linux or macOS shell with
curl and jq installed. - For Azure Blob, a service principal with the permissions Backup and Recovery requires. See the Azure permissions reference for details.
- For AWS S3, an IAM user with an access key pair and the required S3 permissions.
- For ONTAP S3, the fully qualified domain name (FQDN) of the S3 server, plus the access key and secret key of an S3 user.
For the full API reference, see the NetApp Console automation documentation.
Set up authentication for the API
The Console API uses bearer tokens. You first generate a long-lived refresh token in the Console and then exchange it for a short-lived access token that you send with every API call.
Set the API endpoint
Store the base URL of the Console API in an environment variable:
$ export CONSOLE_API=https://cloudmanager.cloud.netapp.com
Generate a refresh token
Open the Refresh Token Generator and generate a long-lived token for your Console account. Store it in an environment variable. Treat this token like a password.
$ export REFRESH_TOKEN="<your-refresh-token>"
Figure 1. Refresh Token Generator page with the Generate Refresh Token button.
Exchange the refresh token for an access token
This call goes to the Auth0 authentication service, not to the Console service. The client identifier in the JSON input is the same constant value for all customers. The access token is valid for a limited time, so repeat this call whenever your calls return an authorization error.
$ export ACCESS_TOKEN=$(
curl -s -X POST "https://netapp-cloud-account.auth0.com/oauth/token" \
-H "Content-Type: application/json" \
-d "{
\"grant_type\": \"refresh_token\",
\"refresh_token\": \"${REFRESH_TOKEN}\",
\"client_id\": \"Mu0V1ywgYteI6w1MbD15fKfVIUrNXGWC\"
}" | jq -r .access_token
)
Collect the account, workspace, and agent IDs
The credential calls need three identifiers: your account ID, your workspace ID, and the ID of the Console agent that connects your environment to NetApp Console.
Find the account ID
List the accounts available to your user:
$ curl -sS "${CONSOLE_API}/tenancy/account" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Accept: application/json" | jq
[
{
"accountPublicId": "<your-account-id>",
"accountName": "TME",
"isSaas": true,
"isGov": false,
"userRole": "Role-1"
},
...
]
In this example, we work with the account named TME. Its accountPublicId is our account ID:
$ export ACCOUNT_ID="<your-account-id>"
You can also find this value in the Console UI. Go to Administration > Identity and Access > Organization, and copy the Organization ID.
Figure 2. Organization page in the Console with the Organization ID highlighted.
Find the workspace ID
The API still uses the term workspace for what the newer Console UI calls a project. List the workspaces in your account:
$ curl -sS -X GET "${CONSOLE_API}/tenancy/account/${ACCOUNT_ID}/workspace" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Accept: application/json" | jq -r '
if type == "array" then .[]
else (.workspaces // .data // .items // []) | .[] end
| [(.workspaceName // .name // "unknown-name"),
(.publicId // .workspacePublicId // .id // "unknown-id")]
| @tsv'
TME Lab <your-workspace-id>
WESTEU <your-workspace-id-2>
Test <your-workspace-id-3>
Store the ID of the workspace you want to use:
$ export WORKSPACE_ID="<your-workspace-id>"
Find the agent ID
In the Console UI, go to Administration > Agents. From the Action menu of your agent, copy the Agent ID:
$ export AGENT_ID="<your-agent-id>"
Figure 3. Agents page in the Console with the Agent ID in the Action menu highlighted.
Confirm the agent belongs to the workspace
The following steps only work if the agent is associated with a workspace. Verify this with the same workspace endpoint, which also returns the associated agents:
$ curl -sS "${CONSOLE_API}/tenancy/account/${ACCOUNT_ID}/workspace" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Accept: application/json" | jq
[
{
"workspacePublicId": "<your-workspace-id>",
"workspaceName": "TME Lab",
"associatedAgents": [
"<your-agent-id>",
"<agent-2>"
]
},
...
]
Our agent appears under TME Lab, so we are ready to continue. If your agent is missing or sits in the wrong workspace, fix it in the Console UI. Go to Administration > Identity and Access > Agents, open the Action menu of the agent, select Associate to folder or project, and choose the right project.
Figure 4. Agents page under Identity and Access with the Associate to Folder or Project action highlighted.
Figure 5. Associate to Folder or Project dialog with the TME Lab project selected.
At this point, you have set these environment variables:
$ export CONSOLE_API="https://cloudmanager.cloud.netapp.com"
$ export REFRESH_TOKEN="<your-refresh-token>"
$ export ACCOUNT_ID="<your-account-id>"
$ export WORKSPACE_ID="<your-workspace-id>"
$ export AGENT_ID="<your-agent-id>"
Add Azure Blob credentials
To back up to Azure Blob, Backup and Recovery uses the credentials of an Azure service principal. Collect these four values:
- Credential name: A name that distinguishes these credentials from others.
- Application (client) ID: The ID of the Microsoft Entra ID service principal used to authenticate.
- Client secret: The value of a client secret for the service principal application.
- Directory (tenant) ID: The Microsoft Entra ID tenant ID of your organization.
Store them in environment variables:
$ export AZURE_CREDENTIAL_NAME="my-azure-backup-creds"
$ export AZURE_CLIENT_ID="<application-client-id>"
$ export AZURE_CLIENT_SECRET="<client-secret>"
$ export AZURE_TENANT_ID="<directory-tenant-id>"
Then add the credentials and associate them with your Console agent. We use jq -n to build the JSON body, which avoids quoting problems with special characters in secrets.
$ curl --request POST --location "${CONSOLE_API}/occm/api/accounts/azure" \
--header "x-agent-id: ${AGENT_ID}" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg accountName "$AZURE_CREDENTIAL_NAME" \
--arg applicationId "$AZURE_CLIENT_ID" \
--arg applicationKey "$AZURE_CLIENT_SECRET" \
--arg tenantId "$AZURE_TENANT_ID" \
'{
accountName: $accountName,
providerKeys: {
applicationId: $applicationId,
applicationKey: $applicationKey,
tenantId: $tenantId
}
}')"
{"publicId":"CloudProviderAccount-riWfN9PM","accountName":"my-azure-backup-creds","accountType":"AZURE_KEYS","tenantId":"<tenant-id>","applicationId":"<client-id>","occmRole":null,"vsaList":[]}
A response that contains a publicId confirms that Backup and Recovery stored the credentials. To double-check, list all cloud provider credentials tied to your agent:
$ curl -sS -X GET --location "${CONSOLE_API}/occm/api/accounts/cloud-providers" \
-H "x-agent-id: ${AGENT_ID}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" | jq
{
"awsAccounts": [],
"azureAccounts": [
{
"publicId": "CloudProviderAccount-aDGUuhYX",
"accountName": "my-azure-backup-creds",
"accountType": "AZURE_KEYS",
"tenantId": "<tenant-id>",
"applicationId": "<client-id>",
"occmRole": null,
"vsaList": []
}
],
"gcpStorageAccounts": [],
"nssAccounts": []
}
You can now discover existing and create new Azure backup destinations. See the Backup and Recovery documentation on how to prepare the backup destination.
Add AWS S3 credentials
With the access key pair of an IAM user that has the required permissions, you can define AWS S3 buckets as backup destinations. Set the name you want to see in Backup and Recovery and the keys:
$ export AWS_ACCOUNT_NAME="my-aws-s3-backup"
$ export AWS_ACCESS_KEY_ID="<access-key-id>"
$ export AWS_SECRET_ACCESS_KEY="<secret-access-key>"
Add the credentials and associate them with the agent:
$ curl -sS --request POST --location "${CONSOLE_API}/occm/api/accounts/aws" \
--header "x-agent-id: ${AGENT_ID}" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg accountName "$AWS_ACCOUNT_NAME" \
--arg accessKey "$AWS_ACCESS_KEY_ID" \
--arg secretKey "$AWS_SECRET_ACCESS_KEY" \
'{
accountName: $accountName,
providerKeys: {
awsAccessKeys: {
accessKey: $accessKey,
secretKey: $secretKey
}
}
}')" | jq
{
"publicId": "CloudProviderAccount-DfmfHELR",
"accountName": "my-aws-s3-backup",
"accountType": "AWS_KEYS",
"accountId": "<aws-account-id>",
"accessKey": "<access-key-id>",
"assumeRole": null,
"occmRole": null,
"vsaList": [],
"subscriptionId": null
}
To verify, list the credentials tied to your agent again. The awsAccounts array now contains the entry you just added:
$ curl -sS -X GET --location "${CONSOLE_API}/occm/api/accounts/cloud-providers" \
-H "x-agent-id: ${AGENT_ID}" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" | jq '.awsAccounts'
[
{
"publicId": "CloudProviderAccount-bRghS8MB",
"accountName": "my-aws-s3-backup",
"accountType": "AWS_KEYS",
"accountId": "<account-id>",
"accessKey": "<access-key-id>",
"assumeRole": null,
"occmRole": null,
"vsaList": [],
"subscriptionId": null
}
]
Add ONTAP S3 credentials
To use an ONTAP S3 bucket as a backup destination, Backup and Recovery needs the FQDN of the ONTAP S3 server, plus the access key and secret key of an S3 user:
$ export ACCESSKEY="<access-key>"
$ export SECRETKEY="<secret-key>"
$ export STORAGE_SERVER="s3.example.com"
ONTAP S3 credentials use a different endpoint, which belongs to the Backup and Recovery service and takes your account ID in the path. The provider value is ONTAP_S3, and the port matches the listener of your S3 server (80 in our lab):
$ curl --request POST "${CONSOLE_API}/backup-recovery/organizations/${ACCOUNT_ID}/v1/credentials" \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--header "X-Agent-Id: ${AGENT_ID}" \
--header "Content-Type: application/json" \
--data "$(jq -n \
--arg provider "ONTAP_S3" \
--arg name "my-bnr-ontaps3-creds" \
--arg server "${STORAGE_SERVER}" \
--arg access_key "${ACCESSKEY}" \
--arg secret_password "${SECRETKEY}" \
'{
provider: $provider,
credential_name: $name,
storage_server_name: $server,
port: 80,
access_key: $access_key,
secret_password: $secret_password
}')"
{"job_id":"ccbdb92c-d884-4f21-a5f1-ff0be6bb072b"}
Unlike the Azure and AWS calls, this call returns a job_id because Backup and Recovery processes the request asynchronously. List the ONTAP S3 credentials to confirm the result:
$ curl -sS --get "${CONSOLE_API}/backup-recovery/organizations/${ACCOUNT_ID}/v1/credentials" --header "Authorization: Bearer ${ACCESS_TOKEN}" --header "Accept: application/json" --header "X-Agent-Id: ${AGENT_ID}" --data-urlencode "provider=ONTAP_S3" | jq
[
{
"credential_uuid": "3f1f60a0-4b9c-42a3-a1aa-d5022d142dc2",
"credential_name": "pu-bnr-ontaps3-creds",
"provider": "ONTAP_S3",
"storage_server_name": "s3.example.com",
"agent_id": "SmUl9eyxbmLZY6LIpv1h0l4oljNbQZ3lclients",
"access_key": "<access-key>",
"gcp": {}
}
]
Tips for production use
- Protect your secrets: Never commit refresh tokens, client secrets, or access keys to source control. Read them from a secrets manager or a protected environment file.
- Refresh the access token: Access tokens expire. In long-running scripts, request a new one before each run.
- Check the response: Test for a
publicId (Azure and AWS) or a job_id (ONTAP S3) in the response and stop the script if it is missing. - Use meaningful credential names: Names such as
prod-azure-westeurope help you pick the right credentials when you create backup destinations later.
Summary
With a refresh token, three identifiers, and a handful of curl calls, you can add Azure Blob, AWS S3, and ONTAP S3 credentials to Backup and Recovery without opening the UI. Wrap these calls in your favorite automation tool, and onboarding a new backup destination becomes a repeatable step in your pipeline instead of a manual task.
Ready to try it? Generate your refresh token, run the examples against a test account, and explore the NetApp Console automation documentation for further API calls. You can find the API calls and command examples in the Verda GitHub repository for easier consumption. Then start protecting your data with NetApp Backup and Recovery.