Hiermee haalt u de tenants voor uw account op.
GET https://management.azure.com/tenants?api-version=2022-12-01
URI-parameters
Name |
In |
Vereist |
Type |
Description |
api-version
|
query |
True
|
string
|
De API-versie die voor deze bewerking moet worden gebruikt.
|
Antwoorden
Name |
Type |
Description |
200 OK
|
TenantListResult
|
OK: retourneert een matrix met tenants.
|
Other Status Codes
|
CloudError
|
Foutreactie waarin wordt beschreven waarom de bewerking is mislukt.
|
Beveiliging
azure_auth
Azure Active Directory OAuth2-stroom
Type:
oauth2
Stroom:
implicit
Autorisatie-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiken
Name |
Description |
user_impersonation
|
uw gebruikersaccount imiteren
|
Voorbeelden
GetAllTenants
Voorbeeldaanvraag
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
Voorbeeldrespons
{
"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": "..."
}
Definities
CloudError
Een foutreactie voor een resourcebeheeraanvraag.
Name |
Type |
Description |
error
|
ErrorResponse
|
Foutreactie
Algemene foutreactie voor alle Azure Resource Manager API's om foutdetails voor mislukte bewerkingen te retourneren. (Dit volgt ook de OData-foutreactieindeling.)
|
ErrorAdditionalInfo
Aanvullende informatie over de resourcebeheerfout.
Name |
Type |
Description |
info
|
object
|
De aanvullende informatie.
|
type
|
string
|
Het type aanvullende informatie.
|
ErrorDetail
De foutdetails.
Name |
Type |
Description |
additionalInfo
|
ErrorAdditionalInfo[]
|
Aanvullende informatie over de fout.
|
code
|
string
|
De foutcode.
|
details
|
ErrorDetail[]
|
De foutdetails.
|
message
|
string
|
Het foutbericht.
|
target
|
string
|
Het foutdoel.
|
ErrorResponse
Foutreactie
Name |
Type |
Description |
error
|
ErrorDetail
|
Het foutobject.
|
TenantCategory
Categorie van de tenant.
Name |
Type |
Description |
Home
|
string
|
|
ManagedBy
|
string
|
|
ProjectedBy
|
string
|
|
TenantIdDescription
Informatie over tenant-id's.
Name |
Type |
Description |
country
|
string
|
Land-/regionaam van het adres voor de tenant.
|
countryCode
|
string
|
Afkorting van land/regio voor de tenant.
|
defaultDomain
|
string
|
Het standaarddomein voor de tenant.
|
displayName
|
string
|
De weergavenaam van de tenant.
|
domains
|
string[]
|
De lijst met domeinen voor de tenant.
|
id
|
string
|
De volledig gekwalificeerde id van de tenant. Bijvoorbeeld /tenants/8d65815f-a5b6-402f-9298-045155da7d74
|
tenantBrandingLogoUrl
|
string
|
De URL van het huisstijllogo van de tenant. Alleen beschikbaar voor de tenantcategorie Home.
|
tenantCategory
|
TenantCategory
|
Categorie van de tenant.
|
tenantId
|
string
|
De tenant-id. Bijvoorbeeld 8d65815f-a5b6-402f-9298-045155da7d74
|
tenantType
|
string
|
Het tenanttype. Alleen beschikbaar voor de tenantcategorie Home.
|
TenantListResult
Informatie over tenant-id's.
Name |
Type |
Description |
nextLink
|
string
|
De URL die moet worden gebruikt om de volgende set resultaten op te halen.
|
value
|
TenantIdDescription[]
|
Een matrix van tenants.
|