from azure.identity import DefaultAzureCredential
from azure.mgmt.subscription import SubscriptionClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-subscription
# 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="83aa47df-e3e9-49ff-877b-94304bf3d3ad",
)
print(response)
# x-ms-original-file: specification/subscription/resource-manager/Microsoft.Subscription/stable/2016-06-01/examples/getSubscription.json
if __name__ == "__main__":
main()
package armsubscription_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/7a2ac91de424f271cf91cc8009f3fe9ee8249086/specification/subscription/resource-manager/Microsoft.Subscription/stable/2016-06-01/examples/getSubscription.json
func ExampleSubscriptionsClient_Get() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armsubscription.NewClientFactory(cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewSubscriptionsClient().Get(ctx, "83aa47df-e3e9-49ff-877b-94304bf3d3ad", 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 = armsubscription.Subscription{
// AuthorizationSource: to.Ptr("Legacy"),
// DisplayName: to.Ptr("Subscription2"),
// ID: to.Ptr("/subscriptions/83aa47df-e3e9-49ff-877b-94304bf3d3ad"),
// State: to.Ptr(armsubscription.SubscriptionStateEnabled),
// SubscriptionID: to.Ptr("83aa47df-e3e9-49ff-877b-94304bf3d3ad"),
// SubscriptionPolicies: &armsubscription.Policies{
// LocationPlacementID: to.Ptr("Internal_2014-09-01"),
// QuotaID: to.Ptr("Internal_2014-09-01"),
// SpendingLimit: to.Ptr(armsubscription.SpendingLimitOff),
// },
// }
}
Stato della sottoscrizione. I valori possibili sono Enabled, Warned, PastDue, Disabled e Deleted.
spendingLimit
Enumerazione
Limite di spesa della sottoscrizione.
Valore
Descrizione
CurrentPeriodOff
Off
On
Subscription
Object
Informazioni sulla sottoscrizione.
Nome
Tipo
Descrizione
authorizationSource
string
Origine di autorizzazione della richiesta. I valori validi sono una o più combinazioni di Legacy, RoleBased, Bypassed, Direct and Management. Ad esempio, "Legacy, RoleBased".
displayName
string
Nome visualizzato della sottoscrizione.
id
string
ID completo per la sottoscrizione. Ad esempio, /subscriptions/000000000-0000-0000-0000-0000000000000000000000.
ID tenant. Ad esempio, 00000000-0000-0000-0000-0000000000000000000.
SubscriptionPolicies
Object
Criteri di sottoscrizione.
Nome
Tipo
Descrizione
locationPlacementId
string
ID di posizionamento della posizione della sottoscrizione. L'ID indica quali aree sono visibili per una sottoscrizione. Ad esempio, una sottoscrizione con un ID di posizionamento della posizione di Public_2014-09-01 ha accesso alle aree pubbliche di Azure.