Open erik-toger opened 1 month ago
This looks specific to Azure Native, so transferring the issue to that repo.
Hi @erik-toger, I haven't worked with WebAppSourceControl
myself, so it's surprising to me that it looks for a user while none is configured in its creation (or can even be configured). What user is it looking for, to authenticate where?
There's one issue on GitHub that suggests it might have to do with the shape of the repo URL. Maybe something worth looking into.
Hello @thomas11 I don't have any references to tree/master or tree/main in my code that the issue that you linked to is referring to.
What user is it looking for, to authenticate where?
The id it is using is the id to my Service Principal, that is logged in both for azure and for pulumi in the pipeline. So I thought it was just some error that "az ad user" was used when "az ad sp" should be used instead. But I'm not sure what is so special about "WebAppSourceControl". Because it manage to create the static web app that is using a github personal access token. So authorizing to github seems to work jus fine.
Im new to pulumi, so It is very likely that I have misunderstood how I should use it. But it works fine from command line.
I'm afraid there might be an issue on the Azure side here. See this (sadly unresolved) issue, for instance: WebApp | Service Principal cannot createOrUpdateSourceControl.
Since the authentication of the WebAppSourceControl
is not configurable at all, I don't think we can do much on the Pulumi side. The fact that your other resources work fine shows that your setup is correct.
Thank you for digging deeper into it. Are you using the azure-sdk-for-js under the hood? In case I want to open a issue over at Azure instead?
It is definitely a Azure bug since I get the same error message if run this in my github actions pipeline:
- name: Create source control directly
run: "az webapp deployment source config --name <web-app-name> --resource-group <RG-name> --repo-url <repo-url> --branch main --github-action true"
So I opened a issue: az webapp deployment source looks for user even if it is called by a Service Prinicpal
Nice, at least we know now where the problem is. Sorry we couldn't help you, though. I'll leave this issue open to track the Azure issue.
What happened?
I get:
azure-native:web:WebAppSourceControl etoger-lp-backend-sourceControl creating (1s) error: Code="NotFound" Message="Cannot find User with name id-for-my-service-principal."
The problem is that it is trying to find a "User" when it should be looking up a "Service Principal". The Id used is actually the Object Id for the Enterprise Application for the service principal, if that detail matters.
Or this is a bug with: https://github.com/pulumi/pulumi-azure-native ???
I have a:
And in Github actions I run:
Example
Github action workflow:
Output of
pulumi about
running 'dotnet build -nologo .' Determining projects to restore...
All projects are up-to-date for restore.
Build succeeded.
Time Elapsed 00:00:05.77
'dotnet build -nologo .' completed successfully CLI Version 3.133.0 Go Version go1.23.1 Go Compiler gc
Plugins KIND NAME VERSION resource azure 6.0.0 resource azure-native 2.62.0 resource azuread 5.53.4 resource command 1.0.1 language dotnet unknown resource github 6.3.0
Host OS Microsoft Windows 11 Pro Version 10.0.22631 Build 22631 Arch x86_64
This project is written in dotnet: executable='C:\Program Files\dotnet\dotnet.exe' version='8.0.401'
Current Stack: erik-toger/learn-pulumi/dev
TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::learn-pulumi::pulumi:pulumi:Stack::learn-pulumi-dev pulumi:providers:github urn:pulumi:dev::learn-pulumi::pulumi:providers:github::etoger-lp-gitHub-provider pulumi:providers:azuread urn:pulumi:dev::learn-pulumi::pulumi:providers:azuread::default_5_53_4 pulumi:providers:azure-native urn:pulumi:dev::learn-pulumi::pulumi:providers:azure-native::default_2_62_0 azuread:index/application:Application urn:pulumi:dev::learn-pulumi::azuread:index/application:Application::etoger-lp-backend-application azure-native:resources:ResourceGroup urn:pulumi:dev::learn-pulumi::azure-native:resources:ResourceGroup::etoger-lp-RG github:index/actionsSecret:ActionsSecret urn:pulumi:dev::learn-pulumi::github:index/actionsSecret:ActionsSecret::etoger-lp-backend-clientIdSecret azuread:index/servicePrincipal:ServicePrincipal urn:pulumi:dev::learn-pulumi::azuread:index/servicePrincipal:ServicePrincipal::etoger-lp-backend-servicePrincipal azuread:index/applicationFederatedIdentityCredential:ApplicationFederatedIdentityCredential urn:pulumi:dev::learn-pulumi::azuread:index/applicationFederatedIdentityCredential:ApplicationFederatedIdentityCredential::etoger-lp-backend-federatedCredential azure-native:authorization:RoleAssignment urn:pulumi:dev::learn-pulumi::azure-native:authorization:RoleAssignment::etoger-lp-backend-servicePrincipal-RoleAssignment azure-native:web:StaticSite urn:pulumi:dev::learn-pulumi::azure-native:web:StaticSite::etoger-lp-frontend-swa azure-native:web:AppServicePlan urn:pulumi:dev::learn-pulumi::azure-native:web:AppServicePlan::etoger-lp-backend-serviceplan azuread:index/servicePrincipalPassword:ServicePrincipalPassword urn:pulumi:dev::learn-pulumi::azuread:index/servicePrincipalPassword:ServicePrincipalPassword::etoger-lp-backend-servicePrincipalPassword github:index/actionsSecret:ActionsSecret urn:pulumi:dev::learn-pulumi::github:index/actionsSecret:ActionsSecret::etoger-lp-frontend-gitHub-secret azure-native:web:WebApp urn:pulumi:dev::learn-pulumi::azure-native:web:WebApp::etoger-lp-backend-WebApp github:index/actionsVariable:ActionsVariable urn:pulumi:dev::learn-pulumi::github:index/actionsVariable:ActionsVariable::etoger-lp-backend-vite-backend-api-url azure-native:documentdb:DatabaseAccount urn:pulumi:dev::learn-pulumi::azure-native:documentdb:DatabaseAccount::etoger-lp-database-account
Found no pending operations associated with dev
Backend
Name pulumi.com URL https://app.pulumi.com/erik-toger User erik-toger Organizations erik-toger Token type personal
Dependencies: NAME VERSION Pulumi 3.67.1 Pulumi.Azure 6.0.0 Pulumi.AzureAD 5.53.4 Pulumi.AzureNative 2.62.0 Pulumi.Command 1.0.1 Pulumi.Github 6.3.0
Pulumi locates its logs in C:\Users\etoger\AppData\Local\Temp by default
Additional context
It works fine from command line since then it is my user that is the caller. But in the Github actions pipeline, then it is the Service Principal that is logged in to Azure and Pulumi. And in the pipeline it managed to create 15 other resources before failing:
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).