APIM Subscription Management (Cheat Sheet)
1️⃣ List All API Management Subscriptions
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions?api-version=2021-08-01" --query "value[].{ID:id, Name:name, DisplayName:properties.displayName, State:properties.state}" --output table
✅ Shows: Subscription Name, Display Name, and State.
2️⃣ Get Details of a Specific Subscription
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions/<subscription-name>?api-version=2021-08-01" --output json
✅ Shows: Creation Date, Scope, Expiry, and Status.
3️⃣ List API Subscription Owners
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions?api-version=2021-08-01" --query "value[].{Name:name, Owner:properties.ownerId, State:properties.state}" --output table
✅ Shows: Subscription Name, Owner ID, and Status.
4️⃣ List Subscriptions and Their Linked Products
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions?api-version=2021-08-01" --query "value[].{Name:name, Product:properties.scope}" --output table
✅ Shows: Subscription Name and the APIM Product it’s linked to.
5️⃣ Export Subscription Data to a File
If you want to save the results to a JSON or CSV file:
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions?api-version=2021-08-01" --output json > apim_subscriptions.json
or for CSV format:
az rest --method get --url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group>/providers/Microsoft.ApiManagement/service/<apim-name>/subscriptions?api-version=2021-08-01" --query "value[].{Name:name, Product:properties.scope}" --output tsv > apim_subscriptions.csv