定义要在 Pulumi 中使用的 Azure-Subscription
Define Azure-Subscription to be used in Pulumi
我使用以下(标准)-Pulumi - 代码来创建一个简单的资源:
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;
}
此操作失败并显示 403,因为它是在不允许我在其中创建资源的订阅中创建的。我有多个订阅,想定义要使用的订阅。我可以使用“GetSubscription”检索当前,但没有找到任何方法来实际设置要使用的订阅。
如何定义要使用的订阅
(我在runnung pulumi up之前使用az login
成功登录)
这里有几个选项:
Select 您使用 Azure CLI 的目标订阅:az account set --subscription SUBSCRIPTION
使用pulumi config set azure:subscriptionId SUBSCRIPTION
。
设置环境变量ARM_SUBSCRIPTION_ID
.
使用Explicit Providers并在提供商的属性中进行配置。
我使用以下(标准)-Pulumi - 代码来创建一个简单的资源:
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;
}
此操作失败并显示 403,因为它是在不允许我在其中创建资源的订阅中创建的。我有多个订阅,想定义要使用的订阅。我可以使用“GetSubscription”检索当前,但没有找到任何方法来实际设置要使用的订阅。
如何定义要使用的订阅
(我在runnung pulumi up之前使用az login
成功登录)
这里有几个选项:
Select 您使用 Azure CLI 的目标订阅:
az account set --subscription SUBSCRIPTION
使用
pulumi config set azure:subscriptionId SUBSCRIPTION
。设置环境变量
ARM_SUBSCRIPTION_ID
.使用Explicit Providers并在提供商的属性中进行配置。