Gets details about a specified subscription.
GET https://management.azure.com/subscriptions/{subscriptionId}?api-version=2022-12-01
URI Parameters
Name |
In |
Required |
Type |
Description |
subscriptionId
|
path |
True
|
string
|
The ID of the target subscription.
|
api-version
|
query |
True
|
string
|
The API version to use for this operation.
|
Responses
Name |
Type |
Description |
200 OK
|
Subscription
|
OK - Returns information about the subscription.
|
Other Status Codes
|
CloudError
|
Error response describing why the operation failed.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name |
Description |
user_impersonation
|
impersonate your user account
|
Examples
GetASingleSubscription
Sample request
GET https://management.azure.com/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05?api-version=2022-12-01
/**
* Samples for Subscriptions Get.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json
*/
/**
* Sample code: GetASingleSubscription.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getASingleSubscription(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().subscriptionClient().getSubscriptions()
.getWithResponse("291bba3f-e0a5-47bc-a099-3bdcb2a50a05", com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import SubscriptionClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-resource
# USAGE
python get_subscription.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = SubscriptionClient(
credential=DefaultAzureCredential(),
)
response = client.subscriptions.get(
subscription_id="291bba3f-e0a5-47bc-a099-3bdcb2a50a05",
)
print(response)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armsubscriptions_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armsubscriptions"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/4f4073bdb028bc84bc3e6405c1cbaf8e89b83caf/specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json
func ExampleClient_Get() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsubscriptions.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewClient().Get(ctx, "291bba3f-e0a5-47bc-a099-3bdcb2a50a05", nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.Subscription = armsubscriptions.Subscription{
// AuthorizationSource: to.Ptr("Bypassed"),
// DisplayName: to.Ptr("Example Subscription"),
// ID: to.Ptr("/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05"),
// ManagedByTenants: []*armsubscriptions.ManagedByTenant{
// {
// TenantID: to.Ptr("8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"),
// }},
// State: to.Ptr(armsubscriptions.SubscriptionStateEnabled),
// SubscriptionID: to.Ptr("291bba3f-e0a5-47bc-a099-3bdcb2a50a05"),
// SubscriptionPolicies: &armsubscriptions.SubscriptionPolicies{
// LocationPlacementID: to.Ptr("Internal_2014-09-01"),
// QuotaID: to.Ptr("Internal_2014-09-01"),
// SpendingLimit: to.Ptr(armsubscriptions.SpendingLimitOff),
// },
// Tags: map[string]*string{
// "tagKey1": to.Ptr("tagValue1"),
// "tagKey2": to.Ptr("tagValue2"),
// },
// TenantID: to.Ptr("31c75423-32d6-4322-88b7-c478bdde4858"),
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { SubscriptionClient } = require("@azure/arm-resources-subscriptions");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Gets details about a specified subscription.
*
* @summary Gets details about a specified subscription.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json
*/
async function getASingleSubscription() {
const subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05";
const credential = new DefaultAzureCredential();
const client = new SubscriptionClient(credential);
const result = await client.subscriptions.get(subscriptionId);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Resources.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json
// this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId);
// invoke the operation
SubscriptionResource result = await subscription.GetAsync();
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
SubscriptionData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/291bba3f-e0a5-47bc-a099-3bdcb2a50a05",
"subscriptionId": "291bba3f-e0a5-47bc-a099-3bdcb2a50a05",
"tenantId": "31c75423-32d6-4322-88b7-c478bdde4858",
"displayName": "Example Subscription",
"state": "Enabled",
"subscriptionPolicies": {
"locationPlacementId": "Internal_2014-09-01",
"quotaId": "Internal_2014-09-01",
"spendingLimit": "Off"
},
"authorizationSource": "Bypassed",
"managedByTenants": [
{
"tenantId": "8f70baf1-1f6e-46a2-a1ff-238dac1ebfb7"
}
],
"tags": {
"tagKey1": "tagValue1",
"tagKey2": "tagValue2"
}
}
Definitions
CloudError
An error response for a resource management request.
Name |
Type |
Description |
error
|
ErrorResponse
|
Error response
Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.).
|
ErrorAdditionalInfo
The resource management error additional info.
Name |
Type |
Description |
info
|
object
|
The additional info.
|
type
|
string
|
The additional info type.
|
ErrorDetail
The error detail.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
code
|
string
|
The error code.
|
details
|
ErrorDetail[]
|
The error details.
|
message
|
string
|
The error message.
|
target
|
string
|
The error target.
|
ErrorResponse
Error response
Name |
Type |
Description |
error
|
ErrorDetail
|
The error object.
|
ManagedByTenant
Information about a tenant managing the subscription.
Name |
Type |
Description |
tenantId
|
string
|
The tenant ID of the managing tenant. This is a GUID.
|
spendingLimit
The subscription spending limit.
Name |
Type |
Description |
CurrentPeriodOff
|
string
|
|
Off
|
string
|
|
On
|
string
|
|
Subscription
Subscription information.
Name |
Type |
Description |
authorizationSource
|
string
|
The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'.
|
displayName
|
string
|
The subscription display name.
|
id
|
string
|
The fully qualified ID for the subscription. For example, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74
|
managedByTenants
|
ManagedByTenant[]
|
An array containing the tenants managing the subscription.
|
state
|
SubscriptionState
|
The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.
|
subscriptionId
|
string
|
The subscription ID.
|
subscriptionPolicies
|
SubscriptionPolicies
|
The subscription policies.
|
tags
|
object
|
The tags attached to the subscription.
|
tenantId
|
string
|
The subscription tenant ID.
|
SubscriptionPolicies
Subscription policies.
Name |
Type |
Description |
locationPlacementId
|
string
|
The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions.
|
quotaId
|
string
|
The subscription quota ID.
|
spendingLimit
|
spendingLimit
|
The subscription spending limit.
|
SubscriptionState
The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.
Name |
Type |
Description |
Deleted
|
string
|
|
Disabled
|
string
|
|
Enabled
|
string
|
|
PastDue
|
string
|
|
Warned
|
string
|
|