azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureRmResource - "Cannot find User with name XXXXXXX"

Open mskutin opened this issue 10 years ago • 15 comments

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

mskutin avatar May 13 '16 10:05 mskutin

@akurmi can you advise on the appropriate way to set sourcecontrols?

markcowl avatar May 16 '16 16:05 markcowl

Adding @davidebbo as he may know how these APIs work.

akurmi avatar May 24 '16 17:05 akurmi

@mskutin are you using a service principal identity? If so, I think there may be some limitations around that. @suwatch is the expert.

davidebbo avatar May 24 '16 18:05 davidebbo

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).

suwatch avatar May 24 '16 20:05 suwatch

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.

suwatch avatar May 25 '16 19:05 suwatch

@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 avatar May 31 '16 22:05 suwatch

@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 avatar Jun 01 '16 02:06 mskutin

@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.

image

Then you can use Azure cmdlet or doing External Repository with your private repo etc.

suwatch avatar Jun 01 '16 17:06 suwatch

@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.

mskutin avatar Jun 02 '16 02:06 mskutin

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.

That's it. Now you can try using Cmdlet to setup publishing from Github or any.

suwatch avatar Jun 02 '16 03:06 suwatch

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 avatar Jun 02 '16 05:06 davidebbo

@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.

mskutin avatar Jun 08 '16 07:06 mskutin

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.

cormacpayne avatar Mar 04 '17 07:03 cormacpayne

I have the same issue with App Service Environment V3:

Cannot find User with name 100320026B8366CA.

amrtappin avatar Jan 25 '23 22:01 amrtappin

You don't have access to resource group. Get access to the resource group as contributor where your wep app is.

ghost avatar Feb 03 '23 12:02 ghost