How do I find my Azure Tenant ID?
To find your Azure Tenant ID, you can use the Azure CLI tool or a simple Terraform script to query it programmatically. Here, we’ll demonstrate how to retrieve the Azure Tenant ID by leveraging the Azure Provider and exposing the Tenant ID as an output.
In this example, we’ll use the Azure Provider to fetch the Tenant ID. The code will configure the Azure Provider using your Azure credentials and then output the Tenant ID.
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = azure.core.getClientConfigOutput({});
export const tenantId = example.apply(example => example.tenantId);
This script does the following:
- Configures the Azure Provider.
- Uses
azurerm_client_config
to access the current Azure context and extract the Tenant ID. - Outputs the Tenant ID for easy retrieval.
Overall, this example shows how to set up the necessary configuration and extract the Azure Tenant ID using the Azure Provider.
Deploy this code
Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.
Sign upNew to Pulumi?
Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.
Sign upThank you for your feedback!
If you have a question about how to use Pulumi, reach out in Community Slack.
Open an issue on GitHub to report a problem or suggest an improvement.