0

我正在尝试在 Azure AD 中建立一个组。

var group = Output.Create(
    GetGroup.InvokeAsync(
        new GetGroupArgs
        {
            Name = "Administrators"
        }));
PS C:\dev\___> pulumi preview
Previewing update (dev):
     Type                 Name          Plan     Info
     pulumi:pulumi:Stack  Frontend-dev           1 error

Diagnostics:
  pulumi:pulumi:Stack (Frontend-dev):
    error: Running program 'C:\dev\___\bin\Debug\netcoreapp3.1\Frontend.dll' failed with an unhandled exception:
    Grpc.Core.RpcException: Status(StatusCode=Unknown, Detail="invocation of azuread:index/getGroup:getGroup returned an error: Error building AzureAD Client: Authenticating using the Azure CLI is only supported as a User (not a Service Principal).

    To authenticate to Azure using a Service Principal, you can use the separate 'Authenticate using a Service Principal'
    auth method - instructions for which can be found here:

    Alternatively you can authenticate using the Azure CLI by using a User Account.")
       at Pulumi.GrpcMonitor.InvokeAsync(InvokeRequest request)
       at Pulumi.Deployment.InvokeAsync[T](String token, InvokeArgs args, InvokeOptions options, Boolean convertResult)
       at Pulumi.Output`1.ApplyHelperAsync[U](Task`1 dataTask, Func`2 func)
       at Pulumi.Output`1.Pulumi.IOutput.GetDataAsync()
       at Pulumi.Serialization.Serializer.SerializeAsync(String ctx, Object prop)
       at Pulumi.Deployment.SerializeFilteredPropertiesAsync(String label, IDictionary`2 args, Predicate`1 acceptKey)
       at Pulumi.Deployment.SerializeAllPropertiesAsync(String label, IDictionary`2 args)
       at Pulumi.Deployment.RegisterResourceOutputsAsync(Resource resource, Output`1 outputs)
       at Pulumi.Deployment.Runner.WhileRunningAsync()

Pulumi.dev.yaml包含服务主体凭据。

我按照说明创建服务主体使用适当的权限对其进行配置

错误消息涉及一些说明:

要使用服务主体对 Azure 进行身份验证,您可以使用单独的“使用服务主体进行身份验证”身份验证方法 - 可在此处找到相关说明:<- 无链接

谁能帮我找到这些说明,以便我可以整理出我可能错过的内容?

4

1 回答 1

0

在文档的某处,我们被要求将凭据放入Pulumi.<stack>.ymlviapulumi config set azure:*命令中,这让我相信这应该足够了。

事情是Pulumi.Azure会在命名空间中查找设置,azurePulumi.AzureAD会在命名空间中查找相同的设置azuread

所以我们不仅需要这个:

pulumi config set azure:clientId "00000000000000000000000"
pulumi config set azure:clientSecret "00000000000000000000000" --secret
pulumi config set azure:tenantId "00000000000000000000000"
pulumi config set azure:subscriptionId "00000000000000000000000"

但我们还需要运行以下命令:

pulumi config set azuread:clientId "00000000000000000000000"
pulumi config set azuread:clientSecret "00000000000000000000000" --secret
pulumi config set azuread:tenantId "00000000000000000000000"
pulumi config set azuread:subscriptionId "00000000000000000000000"

这将使我们得到Pulumi.<stack>.yml类似的结果:

config:
  azure:clientId: 00000000000000000000000
  azure:clientSecret:
    secure: 00000000000000000000000000000000000000000000000XqZFM=
  azure:location: WestEurope
  azure:subscriptionId: 00000000000000000000000
  azure:tenantId: 00000000000000000000000
  azuread:clientId: 00000000000000000000000
  azuread:clientSecret:
    secure: 0000000000000000000000000000000000000000000000l3xbaY=
  azuread:subscriptionId: 00000000000000000000000
  azuread:tenantId: 00000000000000000000000

或者,您也可以在 powershell 中指定环境变量:

$env:ARM_CLIENT_ID="0000000000000000000000000"
$env:ARM_CLIENT_SECRET="0000000000000000000000000"
$env:ARM_TENANT_ID="0000000000000000000000000"
$env:ARM_SUBSCRIPTION_ID="0000000000000000000000000"

之后,我的 Pulumi 堆栈能够成功检索 Azure AD 组对象 ID。

解决 github 问题

于 2020-06-08T13:57:26.117 回答