Obtém os inquilinos da sua conta.
GET https://management.azure.com/tenants?api-version=2022-12-01
Parâmetros do URI
Name |
Em |
Necessário |
Tipo |
Description |
api-version
|
query |
True
|
string
|
A versão da API a utilizar para esta operação.
|
Respostas
Name |
Tipo |
Description |
200 OK
|
TenantListResult
|
OK - Devolve uma matriz de inquilinos.
|
Other Status Codes
|
CloudError
|
Resposta de erro que descreve a razão pela qual a operação falhou.
|
Segurança
azure_auth
Fluxo OAuth2 do Azure Active Directory
Tipo:
oauth2
Fluxo:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Âmbitos
Name |
Description |
user_impersonation
|
representar a sua conta de utilizador
|
Exemplos
GetAllTenants
Pedido de amostra
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 da amostra
{
"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 um pedido de gestão de recursos.
Name |
Tipo |
Description |
error
|
ErrorResponse
|
Resposta a erros
Resposta de erro comum para todas as APIs Resource Manager do Azure para devolver detalhes de erro para operações falhadas. (Isto também segue o formato de resposta de erro OData.).
|
ErrorAdditionalInfo
Informações adicionais sobre o erro de gestão de recursos.
Name |
Tipo |
Description |
info
|
object
|
As informações adicionais.
|
type
|
string
|
O tipo de informação adicional.
|
ErrorDetail
O detalhe do erro.
Name |
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 a erros
Name |
Tipo |
Description |
error
|
ErrorDetail
|
O objeto de erro.
|
TenantCategory
Categoria do inquilino.
Name |
Tipo |
Description |
Home
|
string
|
|
ManagedBy
|
string
|
|
ProjectedBy
|
string
|
|
TenantIdDescription
Informações de ID do inquilino.
Name |
Tipo |
Description |
country
|
string
|
Nome do país/região do endereço do inquilino.
|
countryCode
|
string
|
Abreviatura país/região para o inquilino.
|
defaultDomain
|
string
|
O domínio predefinido do inquilino.
|
displayName
|
string
|
O nome a apresentar do inquilino.
|
domains
|
string[]
|
A lista de domínios do inquilino.
|
id
|
string
|
O ID completamente qualificado do inquilino. Por exemplo, /tenants/8d65815f-a5b6-402f-9298-045155da7d74
|
tenantBrandingLogoUrl
|
string
|
O URL do logótipo de imagem corporativa do inquilino. Apenas disponível para a categoria de inquilino "Home".
|
tenantCategory
|
TenantCategory
|
Categoria do inquilino.
|
tenantId
|
string
|
O ID do inquilino. Por exemplo, 8d65815f-a5b6-402f-9298-045155da7d74
|
tenantType
|
string
|
O tipo de inquilino. Apenas disponível para a categoria de inquilino "Home".
|
TenantListResult
Informações de IDs de inquilino.
Name |
Tipo |
Description |
nextLink
|
string
|
O URL a utilizar para obter o próximo conjunto de resultados.
|
value
|
TenantIdDescription[]
|
Uma matriz de inquilinos.
|