Failed to setup Deployment:Cannot find SourceControltoken with name Bitbucket

Secure Foundations AI 0 Reputation points
2026-08-10T20:43:06.2733333+00:00

Problem type: Technical

Service: App Service

Resource: wa-secure-ai-dev

Problem: Deployment Center / Source Control / Bitbucket integration

Description:

Issue while saving : App Service Deployment Center cannot save Bitbucket source control configuration.

App Service: wa-secure-ai-dev

Resource Group: RG-SECUREAI-DEV

Region: Australia East

Bitbucket OAuth authorization succeeds and Azure creates a valid Microsoft.Web/sourcecontrols/Bitbucket SourceControlToken. The token is retrievable through ARM REST API and has a future expiration time.

However, when Deployment Center saves the Bitbucket configuration, the following operation consistently fails:

Microsoft.Web/sites/sourcecontrols/write

Error:

NotFound - Cannot find SourceControlToken with name Bitbucket.

Extended error code: 51004

We have verified:

Bitbucket authorization succeeds

Fresh OAuth token is generated

Token is accessible through both provider-level and subscription-level ARM REST APIs

App Service is Running

App Service sourcecontrols/web resource has provisioningState Succeeded

Subscription and tenant are correct

Azure CLI is 2.88.0

Repository and branch can be selected successfully

The failure occurs only when Azure performs Microsoft.Web/sites/sourcecontrols/write

Azure App Service
Azure App Service

Azure App Service is a service used to create and deploy scalable, mission-critical web apps.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Allan Solomon Mejia 10,545 Reputation points
    2026-08-11T19:54:21.0466667+00:00

    Hello @Secure Foundations AI

    Thanks for providing the detailed troubleshooting. Based on what you've already verified, this doesn't appear to be a simple Bitbucket authorization failure.

    The important distinction is that the Bitbucket OAuth flow succeeds and Azure creates a Microsoft.Web/sourcecontrols/Bitbucket resource containing the token, but the subsequent App Service operation:

    Microsoft.Web/sites/sourcecontrols/write

    fails with:

    NotFound - Cannot find SourceControlToken with name Bitbucket

    Extended error code: 51004

    Azure App Service stores source-control credentials separately from the site-level source-control configuration. Microsoft documents Microsoft.Web/sourcecontrols as the resource containing properties such as the OAuth access token, refresh token, token secret, and expiration time.

    Since you've confirmed that the Bitbucket token exists and can be retrieved through the ARM APIs, this suggests the failure occurs when the App Service backend attempts to resolve that token while creating/updating the site's source-control configuration, rather than during Bitbucket authentication itself.

    There have also been previous reports of the exact "Cannot find SourceControlToken with name Bitbucket" error during App Service Deployment Center configuration. More recently, users have reported other intermittent failures in the App Service/Bitbucket authorization integration even when the OAuth endpoint successfully returns access and refresh tokens.

    I would first try clearing and recreating the cached App Service source-control token using Azure CLI:

    az webapp deployment source update-token --git-token ""
    

    Then reauthorize Bitbucket from Deployment Center and attempt the configuration again. Microsoft documents az webapp deployment source update-token specifically for updating or clearing the source-control token cached by Azure App Service.

    I would also test whether the failure is tied specifically to Deployment Center by configuring the deployment source through CLI:

    az webapp deployment source config \
      --name wa-secure-ai-dev \
      --resource-group RG-SECUREAI-DEV \
      --repo-url <BITBUCKET-REPOSITORY-URL> \
      --branch <BRANCH> \
      --manual-integration
    

    If the CLI operation returns the same SourceControlToken/51004 error, that would be useful evidence that this isn't simply an Azure Portal UI issue. az webapp deployment source config is Microsoft's supported CLI operation for configuring App Service deployment from a Git repository.

    I would not manually modify the Microsoft.Web/sourcecontrols/Bitbucket token resource unless Microsoft Support specifically recommends doing so. Since the OAuth flow is already generating the token correctly, manually replacing it could mask the underlying token-resolution problem.

    If clearing/re-authorizing the cached token and configuring through CLI both produce the same 51004 error, I think this warrants review by the Azure App Service/Microsoft.Web engineering team.

    Please capture the following from a failed attempt:

    • UTC timestamp
    • App Service name and Azure region
    • Operation/correlation ID from Activity Log
    • Full Microsoft.Web/sites/sourcecontrols/write failure
    • Extended error code 51004
    • Azure CLI --debug output with credentials/tokens removed

    Do not post the subscription ID, OAuth access/refresh tokens, or other sensitive values publicly. If a Microsoft moderator needs those details for escalation, they should be exchanged privately.

    As a temporary workaround, if Deployment Center remains blocked, you could also use a Bitbucket Pipeline to deploy directly to Azure App Service, rather than relying on App Service's Bitbucket OAuth integration.

    Given that authorization, repository enumeration, and branch selection all succeed and the failure occurs specifically during Microsoft.Web/sites/sourcecontrols/write, I would treat this as a source-control token resolution issue within the App Service integration path rather than a basic Bitbucket authorization problem.

    Please "Accept the Answer" if this information helped you. This will help us and others in the community as well.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.