Reputation: 9305
I use the following (standard)-Pulumi - Code to create a simple resource:
public MyStack()
{
var current = Output.Create(GetSubscription.InvokeAsync());
this.CurrentSubscriptionDisplayName = current.Apply(current => current.DisplayName);
// Create an Azure Resource Group
var resourceGroup = new ResourceGroup("dingdongdiehexisttot"); // TODO: Conf
// Create an Azure Storage Account
var storageAccount = new Account("storage", new AccountArgs
{
ResourceGroupName = resourceGroup.Name,
AccountReplicationType = "LRS",
AccountTier = "Standard"
});
// Export the connection string for the storage account
this.ConnectionString = storageAccount.PrimaryConnectionString;
}
this fails with a 403 because it is created in a subscription where I am not allowed to create resources into. I have multiple subscriptions and want to define WHICH subscription to be used. I can retrieve the current using "GetSubscription" but did not find any method to actually SET which subscription to use.
How can I define the subscription to be used
(I successfully logged in using az login
before runnung pulumi up)
Upvotes: 2
Views: 1494
Reputation: 35144
Several options here:
Select your target subscription with the Azure CLI: az account set --subscription SUBSCRIPTION
Use pulumi config set azure:subscriptionId SUBSCRIPTION
.
Set the environment variable ARM_SUBSCRIPTION_ID
.
Use Explicit Providers and configure it in the provider's properties.
Upvotes: 8