Hämtar information om en angiven prenumeration.
GET https://management.azure.com/subscriptions/{subscriptionId}?api-version=2022-12-01
URI-parametrar
Name |
I |
Obligatorisk |
Typ |
Description |
subscriptionId
|
path |
True
|
string
|
ID för målprenumerationen.
|
api-version
|
query |
True
|
string
|
Den API-version som ska användas för den här åtgärden.
|
Svar
Name |
Typ |
Description |
200 OK
|
Subscription
|
OK – Returnerar information om prenumerationen.
|
Other Status Codes
|
CloudError
|
Felsvar som beskriver varför åtgärden misslyckades.
|
Säkerhet
azure_auth
Azure Active Directory OAuth2 Flow
Typ:
oauth2
Flow:
implicit
Auktoriseringswebbadress:
https://login.microsoftonline.com/common/oauth2/authorize
Omfattningar
Name |
Description |
user_impersonation
|
personifiera ditt användarkonto
|
Exempel
GetASingleSubscription
Exempelbegäran
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
Exempelsvar
{
"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"
}
}
Definitioner
CloudError
Ett felsvar för en resurshanteringsbegäran.
Name |
Typ |
Description |
error
|
ErrorResponse
|
Felsvar
Vanliga felsvar för alla Azure Resource Manager API:er för att returnera felinformation för misslyckade åtgärder. (Detta följer även OData-felsvarsformatet.).
|
ErrorAdditionalInfo
Ytterligare information om resurshanteringsfelet.
Name |
Typ |
Description |
info
|
object
|
Ytterligare information.
|
type
|
string
|
Den ytterligare informationstypen.
|
ErrorDetail
Felinformationen.
Name |
Typ |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Ytterligare information om felet.
|
code
|
string
|
Felkoden.
|
details
|
ErrorDetail[]
|
Felinformationen.
|
message
|
string
|
Felmeddelandet.
|
target
|
string
|
Felmålet.
|
ErrorResponse
Felsvar
ManagedByTenant
Information om en klientorganisation som hanterar prenumerationen.
Name |
Typ |
Description |
tenantId
|
string
|
Klientorganisations-ID:t för den hanterande klienten. Det här är ett GUID.
|
spendingLimit
Utgiftsgränsen för prenumerationen.
Name |
Typ |
Description |
CurrentPeriodOff
|
string
|
|
Off
|
string
|
|
On
|
string
|
|
Subscription
Prenumerationsinformation.
Name |
Typ |
Description |
authorizationSource
|
string
|
Begärans auktoriseringskälla. Giltiga värden är en eller flera kombinationer av Legacy, RoleBased, Bypassed, Direct och Management. Till exempel "Legacy, RoleBased".
|
displayName
|
string
|
Prenumerationens visningsnamn.
|
id
|
string
|
Det fullständigt kvalificerade ID:t för prenumerationen. Till exempel /subscriptions/8d65815f-a5b6-402f-9298-045155da7d74
|
managedByTenants
|
ManagedByTenant[]
|
En matris som innehåller klientorganisationer som hanterar prenumerationen.
|
state
|
SubscriptionState
|
Prenumerationstillståndet. Möjliga värden är Aktiverad, Varnad, PastDue, Inaktiverad och Borttagen.
|
subscriptionId
|
string
|
Prenumerations-ID:t.
|
subscriptionPolicies
|
SubscriptionPolicies
|
Prenumerationsprinciperna.
|
tags
|
object
|
Taggarna som är kopplade till prenumerationen.
|
tenantId
|
string
|
Prenumerationens klient-ID.
|
SubscriptionPolicies
Prenumerationsprinciper.
Name |
Typ |
Description |
locationPlacementId
|
string
|
Placerings-ID för prenumerationsplats. ID:t anger vilka regioner som visas för en prenumeration. En prenumeration med platsplacerings-ID:t Public_2014-09-01 har till exempel åtkomst till offentliga Azure-regioner.
|
quotaId
|
string
|
Prenumerationens kvot-ID.
|
spendingLimit
|
spendingLimit
|
Utgiftsgränsen för prenumerationen.
|
SubscriptionState
Prenumerationstillståndet. Möjliga värden är Aktiverad, Varnad, PastDue, Inaktiverad och Borttagen.
Name |
Typ |
Description |
Deleted
|
string
|
|
Disabled
|
string
|
|
Enabled
|
string
|
|
PastDue
|
string
|
|
Warned
|
string
|
|