Obtient les locataires de votre compte.
GET https://management.azure.com/tenants?api-version=2022-12-01
Paramètres URI
Nom |
Dans |
Obligatoire |
Type |
Description |
api-version
|
query |
True
|
string
|
Version de l’API à utiliser pour cette opération.
|
Réponses
Nom |
Type |
Description |
200 OK
|
TenantListResult
|
OK : retourne un tableau de locataires.
|
Other Status Codes
|
CloudError
|
Réponse d’erreur décrivant la raison de l’échec de l’opération.
|
Sécurité
azure_auth
Flux OAuth2 Azure Active Directory
Type:
oauth2
Flux:
implicit
URL d’autorisation:
https://login.microsoftonline.com/common/oauth2/authorize
Étendues
Nom |
Description |
user_impersonation
|
Emprunter l’identité de votre compte d’utilisateur
|
Exemples
GetAllTenants
Exemple de requête
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
Exemple de réponse
{
"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": "..."
}
Définitions
CloudError
Réponse d’erreur pour une demande de gestion des ressources.
Nom |
Type |
Description |
error
|
ErrorResponse
|
Réponse d’erreur
Réponse d’erreur courante pour toutes les API Azure Resource Manager pour retourner les détails de l’erreur concernant les opérations ayant échoué. (Cela suit également le format de réponse d’erreur OData.).
|
ErrorAdditionalInfo
Informations supplémentaires sur l’erreur de gestion des ressources.
Nom |
Type |
Description |
info
|
object
|
Informations supplémentaires
|
type
|
string
|
Type d’informations supplémentaires.
|
ErrorDetail
Détail de l’erreur.
Nom |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Informations supplémentaires sur l’erreur.
|
code
|
string
|
Code d'erreur.
|
details
|
ErrorDetail[]
|
Détails de l’erreur.
|
message
|
string
|
Message d’erreur.
|
target
|
string
|
Cible d’erreur.
|
ErrorResponse
Réponse d’erreur
TenantCategory
Catégorie du locataire.
Nom |
Type |
Description |
Home
|
string
|
|
ManagedBy
|
string
|
|
ProjectedBy
|
string
|
|
TenantIdDescription
Informations d’ID de locataire.
Nom |
Type |
Description |
country
|
string
|
Nom du pays/de la région de l’adresse du locataire.
|
countryCode
|
string
|
Abréviation du pays/de la région pour le locataire.
|
defaultDomain
|
string
|
Domaine par défaut pour le locataire.
|
displayName
|
string
|
Nom complet du locataire.
|
domains
|
string[]
|
Liste des domaines pour le locataire.
|
id
|
string
|
ID complet du locataire. Par exemple, /tenants/8d65815f-a5b6-402f-9298-045155da7d74
|
tenantBrandingLogoUrl
|
string
|
URL du logo de personnalisation du locataire. Disponible uniquement pour la catégorie de locataire « Accueil ».
|
tenantCategory
|
TenantCategory
|
Catégorie du locataire.
|
tenantId
|
string
|
ID de locataire. Par exemple, 8d65815f-a5b6-402f-9298-045155da7d74
|
tenantType
|
string
|
Type de locataire. Disponible uniquement pour la catégorie de locataire « Accueil ».
|
TenantListResult
Informations sur les ID de locataires.
Nom |
Type |
Description |
nextLink
|
string
|
URL à utiliser pour obtenir l’ensemble de résultats suivant.
|
value
|
TenantIdDescription[]
|
Tableau de locataires.
|