Obtém os locatários da sua conta.
GET https://management.azure.com/tenants?api-version=2022-12-01
Parâmetros de URI
Nome |
Em |
Obrigatório |
Tipo |
Description |
api-version
|
query |
True
|
string
|
A versão da API a ser usada para esta operação.
|
Respostas
Nome |
Tipo |
Description |
200 OK
|
TenantListResult
|
OK – retorna uma matriz de locatários.
|
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
GetAllTenants
Solicitação de exemplo
GET https://management.azure.com/tenants?api-version=2022-12-01
/**
* Samples for Tenants List.
*/
public final class Main {
/*
* x-ms-original-file:
* specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json
*/
/**
* Sample code: GetAllTenants.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getAllTenants(com.azure.resourcemanager.AzureResourceManager azure) {
azure.genericResources().manager().subscriptionClient().getTenants().list(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_tenants.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.tenants.list()
for item in response:
print(item)
# x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.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/GetTenants.json
func ExampleTenantsClient_NewListPager() {
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)
}
pager := clientFactory.NewTenantsClient().NewListPager(nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page.TenantListResult = armsubscriptions.TenantListResult{
// Value: []*armsubscriptions.TenantIDDescription{
// {
// CountryCode: to.Ptr("US"),
// DefaultDomain: to.Ptr("aad50.ccsctp.net"),
// DisplayName: to.Ptr("Test_Test_aad50"),
// Domains: []*string{
// to.Ptr("aad50.ccsctp.net")},
// ID: to.Ptr("/tenants/a70a1586-9c4a-4373-b907-1d310660dbd1"),
// TenantCategory: to.Ptr(armsubscriptions.TenantCategoryManagedBy),
// TenantID: to.Ptr("a70a1586-9c4a-4373-b907-1d310660dbd1"),
// TenantType: to.Ptr("AAD"),
// },
// {
// CountryCode: to.Ptr("US"),
// DefaultDomain: to.Ptr("auxteststagemanual.ccsctp.net"),
// DisplayName: to.Ptr("Contoso Corp."),
// Domains: []*string{
// to.Ptr("auxteststagemanual.ccsctp.net")},
// ID: to.Ptr("/tenants/83abe5cd-bcc3-441a-bd86-e6a75360cecc"),
// TenantCategory: to.Ptr(armsubscriptions.TenantCategoryHome),
// TenantID: to.Ptr("83abe5cd-bcc3-441a-bd86-e6a75360cecc"),
// TenantType: to.Ptr("AAD"),
// },
// {
// CountryCode: to.Ptr("US"),
// DefaultDomain: to.Ptr("rdvmohoro.ccsctp.net"),
// DisplayName: to.Ptr("TEST_TEST_RDV"),
// Domains: []*string{
// to.Ptr("rdvmohoro.ccsctp.net"),
// to.Ptr("rdvmohoro.mail.ccsctp.net"),
// to.Ptr("rdvmohoro.com")},
// ID: to.Ptr("/tenants/daea2e9b-847b-4c93-850d-2aa6f2d7af33"),
// TenantBrandingLogoURL: to.Ptr("logo1.logo.rdvmohoro.com"),
// TenantCategory: to.Ptr(armsubscriptions.TenantCategoryProjectedBy),
// TenantID: to.Ptr("daea2e9b-847b-4c93-850d-2aa6f2d7af33"),
// TenantType: to.Ptr("AAD"),
// }},
// }
}
}
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 the tenants for your account.
*
* @summary Gets the tenants for your account.
* x-ms-original-file: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetTenants.json
*/
async function getAllTenants() {
const credential = new DefaultAzureCredential();
const client = new SubscriptionClient(credential);
const resArray = new Array();
for await (let item of client.tenants.list()) {
resArray.push(item);
}
console.log(resArray);
}
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/GetTenants.json
// this example is just showing the usage of "Tenants_List" 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);
TenantCollection collection = client.GetTenants();
// invoke the operation and iterate over the result
await foreach (TenantResource item in collection.GetAllAsync())
{
// the variable item 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
TenantData resourceData = item.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Console.WriteLine($"Succeeded");
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
{
"value": [
{
"id": "/tenants/a70a1586-9c4a-4373-b907-1d310660dbd1",
"tenantId": "a70a1586-9c4a-4373-b907-1d310660dbd1",
"countryCode": "US",
"displayName": "Test_Test_aad50",
"domains": [
"aad50.ccsctp.net"
],
"tenantCategory": "ManagedBy",
"defaultDomain": "aad50.ccsctp.net",
"tenantType": "AAD"
},
{
"id": "/tenants/83abe5cd-bcc3-441a-bd86-e6a75360cecc",
"tenantId": "83abe5cd-bcc3-441a-bd86-e6a75360cecc",
"countryCode": "US",
"displayName": "Contoso Corp.",
"domains": [
"auxteststagemanual.ccsctp.net"
],
"tenantCategory": "Home",
"defaultDomain": "auxteststagemanual.ccsctp.net",
"tenantType": "AAD"
},
{
"id": "/tenants/daea2e9b-847b-4c93-850d-2aa6f2d7af33",
"tenantId": "daea2e9b-847b-4c93-850d-2aa6f2d7af33",
"countryCode": "US",
"displayName": "TEST_TEST_RDV",
"domains": [
"rdvmohoro.ccsctp.net",
"rdvmohoro.mail.ccsctp.net",
"rdvmohoro.com"
],
"tenantCategory": "ProjectedBy",
"defaultDomain": "rdvmohoro.ccsctp.net",
"tenantType": "AAD",
"tenantBrandingLogoUrl": "logo1.logo.rdvmohoro.com"
}
],
"nextLink": "..."
}
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
Os detalhes 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.
|
TenantCategory
Categoria do locatário.
Nome |
Tipo |
Description |
Home
|
string
|
|
ManagedBy
|
string
|
|
ProjectedBy
|
string
|
|
TenantIdDescription
Informações de ID do locatário.
Nome |
Tipo |
Description |
country
|
string
|
Nome do país/região do endereço do locatário.
|
countryCode
|
string
|
Abreviação de país/região para o locatário.
|
defaultDomain
|
string
|
O domínio padrão para o locatário.
|
displayName
|
string
|
O nome de exibição do locatário.
|
domains
|
string[]
|
A lista de domínios para o locatário.
|
id
|
string
|
A ID totalmente qualificada do locatário. Por exemplo, /tenants/8d65815f-a5b6-402f-9298-045155da7d74
|
tenantBrandingLogoUrl
|
string
|
A URL do logotipo de identidade visual do locatário. Disponível apenas para a categoria de locatário 'Home'.
|
tenantCategory
|
TenantCategory
|
Categoria do locatário.
|
tenantId
|
string
|
A ID do locatário. Por exemplo, 8d65815f-a5b6-402f-9298-045155da7d74
|
tenantType
|
string
|
O tipo de locatário. Disponível apenas para a categoria de locatário 'Home'.
|
TenantListResult
Informações de Ids de locatário.
Nome |
Tipo |
Description |
nextLink
|
string
|
A URL a ser usada para obter o próximo conjunto de resultados.
|
value
|
TenantIdDescription[]
|
Uma matriz de locatários.
|