Azure Cannot find SourceControlToken

AaronH20 36 Reputation points
2022-12-14T21:55:44.26+00:00

270743-image-2022-12-14-214802137.png

I'm trying to upload my code via Github on a Azure Web App. I've authorised my github account, selected the rep & branch and I retrieve the error seen in photo when I try to save it.

Any Fixes for this?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,828 questions
0 comments No comments
{count} votes

5 answers

Sort by: Most helpful
  1. Don Heuvelman 15 Reputation points
    2023-01-29T19:54:13.78+00:00

    I'm following this LAB: https://learn.microsoft.com/en-us/azure/app-service/tutorial-dotnetcore-sqldb-app?pivots=platform-linux&source=docs#3-deploy-sample-code

    And stumbled upon the same error, stating Azure cannot find SourceControlToken with name GitHub

    I tried @Patrick Tchakoute solution, and I think I've saved my settings 6 or 7 times now. I checked GitHub Authorized OAuth Apps, which shows me the Azure App Service (which I just granted).. I revoked that and restarted the Deployment Center within the Azure Portal App Service. I allowed Azure again on my GitHub account.. so I can read my account and select the desired Repository and Branch. But as soon as I hit 'Save' the same SourceControlToken error pops-up.

    So I let it rest for a minute or 15 or so.. made myself some tea and now all of a sudden I could Save successfully. So it seemed that waiting a while (like 15 to 20 minutes) did the trick.

    3 people found this answer helpful.

  2. Grmacjon-MSFT 15,606 Reputation points
    2022-12-15T05:03:11.567+00:00

    Hi @AaronH20 ,

    We are sorry to hear you are facing difficulties setting up your Azure Web App via Github. Can you please share the documentation you used to set up your GitHub account? Is this a Windows or Linux web app?

    You may want to allow Azure Portal to use your Github account token to access Github resources. You will need to add Azure Portal as an Authorized OAuth App in Applications settings of your Github account.

    Best,
    Grace

    1 person found this answer helpful.

  3. Sarang Brahme 1 Reputation point
    2023-04-03T21:44:51.0533333+00:00

    I had the same issue, and following things worked for me:

    • In Github settings: Revoked permissions for Azure App Service and Azure App Service Creates
    • In Azure Portal -> Web app -> Deployment -> Deployment Center -> Settings - disconnect from current Github connection and re-authorize. Then Save.
    • Wait for some time ~3-5 min, because apparently it takes some time to update ( at least in my case I tried immediately after it and could not save the settings.
    0 comments No comments

  4. HP 245 G7 0 Reputation points
    2023-04-05T15:25:45.4133333+00:00

    I am getting similar error . I have set up azure service as gihub Oauth app, provided all the persmissions and still i get this error : Edit 1 : Guys just wait. For some reason, the Git & azure connection does not happen instantly as it should but after maybe 15 minutes. Mine connected after 15 minutes

    Failed to set up deployment: <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>BadRequest</Code><Message>Repository 'UpdateSiteSourceControl' operation failed with Microsoft.Web.Hosting.SourceControls.OAuthException: GitHub GetSecretsPublicKey: Bad credentials&#xD;
       at Microsoft.Web.Hosting.SourceControls.GitHubProxy.&lt;ProcessResponse&gt;d__31`1.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.SourceControls.GitHubProxy.&lt;GetSecretsPublicKey&gt;d__22.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.GitHubActionRepositoryProvider.&lt;CreateOrUpdateGitHubActionSecret&gt;d__19.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.GitHubActionRepositoryProvider.&lt;UpdateSiteSourceControl&gt;d__16.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.WebCloudController.&lt;&gt;c__DisplayClass348_1.&lt;&lt;UpdateSiteSourceControl&gt;b__1&gt;d.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.AsyncHelper.RunSync[TResult](Func`1 func)&#xD;
       at Microsoft.Web.Hosting.Administration.WebCloudController.UpdateSiteSourceControl(String subscriptionName, String webspaceName, String name, SiteSourceControl siteSourceControl).</Message><ExtendedCode>05007</ExtendedCode><MessageTemplate>Repository '{0}' operation failed with {1}.</MessageTemplate><Parameters xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:string>UpdateSiteSourceControl</a:string><a:string>Microsoft.Web.Hosting.SourceControls.OAuthException: GitHub GetSecretsPublicKey: Bad credentials&#xD;
       at Microsoft.Web.Hosting.SourceControls.GitHubProxy.&lt;ProcessResponse&gt;d__31`1.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.SourceControls.GitHubProxy.&lt;GetSecretsPublicKey&gt;d__22.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.GitHubActionRepositoryProvider.&lt;CreateOrUpdateGitHubActionSecret&gt;d__19.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.GitHubActionRepositoryProvider.&lt;UpdateSiteSourceControl&gt;d__16.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.Administration.WebCloudController.&lt;&gt;c__DisplayClass348_1.&lt;&lt;UpdateSiteSourceControl&gt;b__1&gt;d.MoveNext()&#xD;
    --- End of stack trace from previous location where exception was thrown ---&#xD;
       at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()&#xD;
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)&#xD;
       at Microsoft.Web.Hosting.AsyncHelper.RunSync[TResult](Func`1 func)&#xD;
       at Microsoft.Web.Hosting.Administration.WebCloudController.UpdateSiteSourceControl(String subscriptionName, String webspaceName, String name, SiteSourceControl siteSourceControl)</a:string></Parameters><InnerErrors i:nil="true"/><Details i:nil="true"/><Target i:nil="true"/></Error>
    
    0 comments No comments

  5. tester 0 Reputation points
    2023-10-12T20:51:36.38+00:00

    I'm using Azure SDK for JavaScript to create App Service Plan and Web App. I get the Cannot find SourceControlToken with name GitHub error when I create the source control for a private GitHub repo.

    Below is the function I'm using:

    async function webApps_beginCreateOrUpdateSourceControlAndWait() {
        const parameter = {
            repoUrl: "https://github.com/<user>/<name>",
            branch: "main",
            securityToken: {
                accessToken: "******",
                tokenType: "PersonalAccessToken"
            },
        };
        await client.webApps
            .beginCreateOrUpdateSourceControlAndWait(resourceGroup, appName, parameter)
            .then((res) => {
                console.log(res);
            });
    } 
    

    Here's what I've tried so far:

    • Checked that the source control works for a public GitHub repo.
    • Linked Azure and GitHub within Deployment Center in Azure Portal. Revoked from GitHub and linked again as suggested in other posts.
    • Checked in the Azure Resource Explorer that the token is defined at providers/Microsoft.Web/sourcecontrols/GitHub.
    • Assigned Owner, Contributor, and Website Contributor roles to the registered app.
    0 comments No comments