Closed stooj closed 4 months ago
Here's my initial analysis ...
This error is either coming from:
It must be the second, because getting auth config:
doesn't appear in the error message.
The definition for getOAuthToken which contains the error string empty token from %T
. Here's the logic to fetch the token:
This is trying to cast the authorizer
(autorest.Authorizer
) into either a autorest.BearerAuthorizer
or hamiltonAuth.Authorizer
. When using MSI, we should be using the managedServiceIdentityAuth
method in go-azure-helpers
. It appears this is returning a BearerAuthorizer so should be correct.
@stooj, does the VM have a system- or user-assigned identity? Can you double check your clientId
config - it should be unset for system identity and set for user identity.
I was using a User Assigned Identity.
I've got the whole recreation in the initial issue description for recreating from start to finish. I'm not setting clientId
anywhere manually and I'm not manually logging into azure once I've created the VM.
var userAssignedIdentity = new AzureNative.ManagedIdentity.UserAssignedIdentity("userAssignedIdentity", new()
{
Location = resourceGroup.Location,
ResourceGroupName = resourceGroup.Name,
ResourceName = "stoo-uaid-msi-test",
});
My instructions were maybe misleading there because I do run az account show
on my local dev machine to retrieve the subscriptionId
I think our docs might be wrong here, and you do need to configure clientId
for user-managed identities. You should be able to find the id of your identity in the portal. Can you give that a try?
Sure thing.
Tried to set the clientId
using an env var and in the pulumi config, but I still got the same error.
The original reporter is using a System Managed Identity as well; I used a User Managed one because it was easier to set up, but they both show the same error.
What I didn't set was the tenantId
on the VM. After configuring that I was able to create a StorageAccount
from inside the VM.
Just to complete the (closed) loop here, this was fixed somewhere.
Using latest pulumi latest (3.122.0 at writing) I'm able to retrieve the client token in my test azure vm, even if tenantId
is not set.
This still does not work for us with the latest Pulumi version as of this writing.
What happened?
On a hosted VM with a Managed Identity, pulumi can't retrieve the client token.
Running the following inside pulumi:
crashes with the following:
Example
Here's a sample program to trigger the issue:
Here's a separate pulumi project to bootstrap a test environment in Azure:
Sample
csproj
file:Pulumi code:
To reproduce, ssh into the VM and start a pulumi program using useMsi or the
ARM_USE_MSI
env variable.Output of
pulumi about
Additional context
No response
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).