Obtém detalhes sobre uma assinatura especificada.
GET https://management.azure.com/subscriptions/{subscriptionId}?api-version=2022-12-01
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
subscriptionId
|
path |
True
|
string
|
A ID da assinatura de destino.
|
api-version
|
query |
True
|
string
|
A versão da API a ser usada para esta operação.
|
Respostas
Nome |
Tipo |
Description |
200 OK
|
Subscription
|
OK – retorna informações sobre a assinatura.
|
Other Status Codes
|
CloudError
|
Resposta de erro que descreve por que a operação falhou.
|
Segurança
azure_auth
Fluxo do OAuth2 do Azure Active Directory
Tipo:
oauth2
Flow:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Escopos
Nome |
Description |
user_impersonation
|
representar sua conta de usuário
|
Exemplos
GetASingleSubscription
Solicitação de exemplo
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://video2.skills-academy.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
Resposta de exemplo
{
"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"
}
}
Definições
CloudError
Uma resposta de erro para uma solicitação de gerenciamento de recursos.
Nome |
Tipo |
Description |
error
|
ErrorResponse
|
Resposta de erro
Resposta de erro comum para todas as APIs do Azure Resource Manager para retornar detalhes de erro de operações com falha. (Isso também segue o formato de resposta de erro OData.).
|
ErrorAdditionalInfo
As informações adicionais do erro de gerenciamento de recursos.
Nome |
Tipo |
Description |
info
|
object
|
As informações adicionais.
|
type
|
string
|
O tipo de informação adicional.
|
ErrorDetail
O detalhe do erro.
Nome |
Tipo |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
As informações adicionais do erro.
|
code
|
string
|
O código de erro.
|
details
|
ErrorDetail[]
|
Os detalhes do erro.
|
message
|
string
|
A mensagem de erro.
|
target
|
string
|
O destino do erro.
|
ErrorResponse
Resposta de erro
Nome |
Tipo |
Description |
error
|
ErrorDetail
|
O objeto de erro.
|
ManagedByTenant
Informações sobre um locatário que gerencia a assinatura.
Nome |
Tipo |
Description |
tenantId
|
string
|
A ID do locatário de gerenciamento. É um GUID.
|
spendingLimit
O limite de gastos da assinatura.
Nome |
Tipo |
Description |
CurrentPeriodOff
|
string
|
|
Off
|
string
|
|
On
|
string
|
|
Subscription
Informações de assinatura.
Nome |
Tipo |
Description |
authorizationSource
|
string
|
A origem da autorização da solicitação. Os valores válidos são uma ou mais combinações de Legacy, RoleBased, Bypassed, Direct e Management. Por exemplo, 'Legacy, RoleBased'.
|
displayName
|
string
|
O nome de exibição da assinatura.
|
id
|
string
|
A ID totalmente qualificada para a assinatura. Por exemplo, /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74
|
managedByTenants
|
ManagedByTenant[]
|
Uma matriz que contém os locatários que gerenciam a assinatura.
|
state
|
SubscriptionState
|
O estado da assinatura. Os valores possíveis são Habilitado, Avisado, PastDue, Desabilitado e Excluído.
|
subscriptionId
|
string
|
A ID da assinatura.
|
subscriptionPolicies
|
SubscriptionPolicies
|
As políticas de assinatura.
|
tags
|
object
|
As marcas anexadas à assinatura.
|
tenantId
|
string
|
A ID do locatário da assinatura.
|
SubscriptionPolicies
Políticas de assinatura.
Nome |
Tipo |
Description |
locationPlacementId
|
string
|
A ID de posicionamento do local da assinatura. A ID indica quais regiões estão visíveis para uma assinatura. Por exemplo, uma assinatura com uma ID de posicionamento de local de Public_2014-09-01 tem acesso a regiões públicas do Azure.
|
quotaId
|
string
|
A ID da cota de assinatura.
|
spendingLimit
|
spendingLimit
|
O limite de gastos da assinatura.
|
SubscriptionState
O estado da assinatura. Os valores possíveis são Habilitado, Avisado, PastDue, Desabilitado e Excluído.
Nome |
Tipo |
Description |
Deleted
|
string
|
|
Disabled
|
string
|
|
Enabled
|
string
|
|
PastDue
|
string
|
|
Warned
|
string
|
|