Set-AzureRmResource - "Cannot find User with name XXXXXXX"
Unable to set Microsoft.Web/sites/sourcecontrols settings always get into the same error:
$PropertiesObject = @{
RepoUrl='https://github.com/organization/repo.git';
Branch='branch';
IsManualIntegration='False';
DeploymentRollbackEnabled='False';
IsMercurial='False';
ProvisioningState='Succeeded'
}
Set-AzureRmResource -PropertyObject $PropertiesObject `
-ResourceGroupName $ResourceGroupName `
-ResourceType Microsoft.Web/sites/sourcecontrols `
-ResourceName $ResourceName/web `
-ApiVersion 2015-08-01 -Force
Set-AzureRmResource : The pipeline has been stopped.
At line:3 char:1
+ Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmResource], PipelineStoppedException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureResourceCmdlet
Set-AzureRmResource : {"Code":"NotFound","Message":"Cannot find User with name
10030000XXXXXX.","Target":null,"Details":[{"Message":"Cannot find User with name
10030000XXXXXX."},{"Code":"NotFound"},{"ErrorEntity":{"Code":"NotFound","Message":"Cannot find User with name
10030000XXXXXX.","ExtendedCode":"51004","MessageTemplate":"Cannot find {0} with name
{1}.","Parameters":["User","10030000XXXXXX"],"InnerErrors":null}}],"Innererror":null}
At line:3 char:1
+ Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : NotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.SetAzureResourceCmdlet
@akurmi can you advise on the appropriate way to set sourcecontrols?
Adding @davidebbo as he may know how these APIs work.
@mskutin are you using a service principal identity? If so, I think there may be some limitations around that. @suwatch is the expert.
Correct, we don't support service principal identity.
If you were just using typical user account, make sure you log on to portal with this same account and setup deployment of any webapp with Github once (involving OAuth flow).
A few corrections.
- Looking at the error above, this implied that user did not use Service Principal. It is interact user (with PUID: 100300XXX) account. @mskutin, try logon to portal and perform setup continuous deployment thru portal ui once. Then retry your scenario with cmdlet again. If still failed, share us the sitename, time and timezone.
10030000XXXXXX."},{"Code":"NotFound"},{"ErrorEntity":{"Code":"NotFound","Message":"Cannot find User with name
- I reviewed our internal codes for setup sourcecontrol, we do support set up using Service Prinicipal. I did try and it worked great. The tricky part is one must first generate the github oauth token and call this api to associate the token with Service Principal.
@mskutin are you still having issue? If yes, first please clarify whether you were using service principal? Also do include time frame of the failure and site name (here or indirectly).
@suwatch, whether or not service principle I still have.
I thought we discuss this by email, ticket number is [216051214155825001]
try logon to portal and perform setup continuous deployment thru portal ui once.
Here is what I have:
• DESCRIPTION Failed to set up deployment source for web app b***-a**-*****ge, using External Repository. {"Code":"NotFound","Message":"Cannot find SourceControlToken with name GitHub.","Target":null,"Details":[{"Message":"Cannot find SourceControlToken with name GitHub."},{"Code":"NotFound"},{"ErrorEntity":{"Code":"NotFound","Message":"Cannot find SourceControlToken with name GitHub.","ExtendedCode":"51004","MessageTemplate":"Cannot find {0} with name {1}.","Parameters":["SourceControlToken","GitHub"],"InnerErrors":null}}],"Innererror":null} • STATUS Error • TIME Thursday, May 26, 2016, 12:55:50 PM • CORRELATION IDS dab3c322-b4c7-4895-ac1d-580bedd79565
@mskutin Sorry I must have missed that conversation on the mail thread.
My apology as I wasn't being clear about try logon to portal and perform setup continuous deployment thru portal ui once. What I meant was you must go thru portal with that same account and try to setup GitHub (not External) continuous integration (hilited below) once. This will lead you to perform the OAuth flow with Github. As a result, the Github token will be established for this particular account. Again you only need to do this once.

Then you can use Azure cmdlet or doing External Repository with your private repo etc.
@suwatch what about this https://azure.microsoft.com/en-us/updates/automation-run-as-account/ ? Do I need to go through the procedure above for this type of accounts? I cannot login using this account since it doesn't have a password. So I can't setup GitHub deployment.
Correct, since you can't log on with service principal, you can't perform oauth flow via Portal UI in order to associate Github token with service principal account.
Good news is there is a manual step you could do. Below explains how to achieve this using ARMClient. @davidebbo might know how to achieve via cmdlet powershell.
- Install ARMClient (simply chocolatey) see readme.
- Run ARMClient spn command to logon with appId and appKey.
- Follow the first two steps to generate Github OAuth token and store it with Azure.
That's it. Now you can try using Cmdlet to setup publishing from Github or any.
PowerShell would look something like this:
$PropertiesObject = @{
token = "yourgithubtoken";
}
Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceId /providers/Microsoft.Web/sourcecontrols/GitHub -ApiVersion 2015-08-01 -Force
And this article explains how to login with service principal to PowerShell.
@davidebbo @suwatch Thanks for the explanations, I confirm that everything above works after this:
What I meant was you must go thru portal with that same account and try to setup GitHub (not External) continuous integration (hilited below) once.
Closing this issue as it appears to be resolved.
@mskutin please feel free to reopen this issue if it wasn't resolved and/or you have any other questions.
I have the same issue with App Service Environment V3:
Cannot find User with name 100320026B8366CA.
You don't have access to resource group. Get access to the resource group as contributor where your wep app is.