Cannot find SourceControlToken with name GitHub
I have an Azure Bicep file which creates an Azure Function App and Deploys code from a repository to that function app. When I run this file locally, it runs perfectly but when I run it on azure devops portal it throws the following error: Cannot find SourceControlToken with name GitHub on Azure Devops Portal. I'm using this to upload the code to app. The code works perfectly when I run it locally. But when I try to run this on the devops portal it throws error.
resource sourcecontrol 'Microsoft.Web/sites/sourcecontrols@2022-09-01' = {
parent: azureFunction
name: 'web'
properties: {
repoUrl: pRepoUrl
branch: pBranchName
isManualIntegration: true
}
}
Azure Functions
-
MuthuKumaranMurugaachari-MSFT 22,146 Reputation points
2023-08-24T19:23:35.69+00:00 Niraj Thanks for posting your question in Microsoft Q&A. I assume you have followed template specified in Customizing a deployment doc and faced the above error.
Have you configured the source in Deployment center like described in Set up continuous deployment? Checkout similar discussion related to the same error and make sure the permissions are set up correctly.
-
Niraj 40 Reputation points
2023-08-25T06:38:20.66+00:00 I'm trying to do it programatically. I dont want to manually go to portal and do the configuration. I have a script which creates two different azure functions and want to deploy two code from two different git repos.
-
Niraj 40 Reputation points
2023-08-28T09:59:28.11+00:00 Is it even possible to deploy code programatically?
-
MuthuKumaranMurugaachari-MSFT 22,146 Reputation points
2023-08-29T14:29:28.6566667+00:00 Niraj The above portal option lets you configure Function app with your GitHub repository (for credentials). However, if you are looking to do the same via code, you can check out the guide Set up a workflow manually which talks about the steps specifically for GitHub actions. These steps may vary depending on CI/CD such as Azure Repos, Bitbucket etc.
-
Niraj 40 Reputation points
2023-08-31T05:27:36.0233333+00:00 I want to do it through the bicep file. The above documentation is not helpful. I have a bicep file whom I give a name and it creates and azure function and queue and want it to upload the code from github. I dont want to create yml file everytime for new customer. Want to automate it. The code works locally but doesnt work on auzre devops portal
-
MuthuKumaranMurugaachari-MSFT 22,146 Reputation points
2023-08-31T13:43:35.95+00:00 Niraj I would like to understand on the part how you deploy the bicep template?
You can use a bicep template to create an Azure Functions like you mentioned above, however for continuous deployment of the code, Azure Functions need to have authorization for accessing GitHub repo (so that App Service/Functions can access the code repository and deploy it). This can be achieved by using Set up continuous deployment in the portal or Set up a workflow manually option.
Azure Function deployment would still be bicep file but authorization of external repo such as GitHub or Azure repos have to either one of the above options. I hope this helps and let me know if any questions.
-
Niraj 40 Reputation points
2023-08-31T17:03:43.78+00:00 This is my code
The reference to the code is from here: https://learn.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code?tabs=bicep. In this at the end they pass the function object to the source control and just add the repo url and branch. this script works locally but doesnt run when I run it in Azure Devops Portal. Also In devops portal I have given Azure the access to githubresource azureFunction 'Microsoft.Web/sites@2022-09-01' = { name: pFunctionAppName location: pLocation kind: 'functionapp,linux' identity: { type: 'SystemAssigned' } properties: { serverFarmId: pServerFarmId httpsOnly: true siteConfig: { linuxFxVersion: 'python|3.10' alwaysOn: true ftpsState: 'FtpsOnly' minTlsVersion: '1.2' appSettings: [ { name: 'AzureWebJobsStorage' value: 'DefaultEndpointsProtocol=https;AccountName=${pStorageAccountName};AccountKey=${listKeys(pStorageAcountId, '2022-09-01').keys[0].value}' } { name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING' value: 'DefaultEndpointsProtocol=https;AccountName=${pStorageAccountName};AccountKey=${listKeys(pStorageAcountId, '2022-09-01').keys[0].value}' } { name: 'WEBSITE_CONTENTSHARE' value: toLower(pFunctionAppName) } { name: 'FUNCTIONS_EXTENSION_VERSION' value: '~4' } { name: 'APPINSIGHTS_INSTRUMENTATIONKEY' value: azAppInsights.properties.InstrumentationKey } { name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' value: azAppInsights.properties.ConnectionString } { name: 'FUNCTIONS_WORKER_RUNTIME' value: 'python' } ] } } } resource sourcecontrol 'Microsoft.Web/sites/sourcecontrols@2022-09-01' = { parent: azureFunction name: 'web' properties: { // repoUrl: pRepoUrl // branch: pBranchName isManualIntegration: false } }
-
Niraj 40 Reputation points
2023-08-31T17:04:55.46+00:00 My end goal is to automate things. I dont want to go on azure portal and manually configure the github stuff. I want it to be done through the bicep file. This works locally but not in devops portal
-
Niraj 40 Reputation points
2023-08-31T17:06:11.53+00:00 This is my code in yml file which runs the bicep file in devops portal. Just a small snippet as I cant show all of the code
trigger: none steps: - task: AzureCLI@2 displayName: 'Deploy Bicep Template' inputs: azureSubscription: $(azureSubscription) scriptType: 'bash' scriptLocation: 'inlineScript' inlineScript: | az deployment group create --name pipeline-bicep-file-deployment-${{ parameters.pTenantName }} --resource-group ${{ variables.resourceGroupName}} --template-file bicep_files/service.bicep --parameters tenantName=${{ parameters.pTenantName }} --verbose
-
Niraj 40 Reputation points
2023-09-04T12:13:35.1466667+00:00 What should I do in this case?
-
MuthuKumaranMurugaachari-MSFT 22,146 Reputation points
2023-09-06T14:10:21.8066667+00:00 Niraj Sorry for the delay in response. We will need to review the deployment, backend logs, and also looking to get some additional information from you. Please send an email to
azcommunity@microsoft.com
referencing this thread with your subscription ID (not name), Function app details and subject as "Attn: Muthu". I will assist you with next steps offline. -
Niraj 40 Reputation points
2023-09-06T17:42:55.8+00:00 yeah will do that
-
AP Mossevig 20 Reputation points
2024-04-25T08:08:52.4466667+00:00 Hi, was this ever resolved? I have the same problem, I want to set up the CI/CD (the github action integration) as part of the bicep template, and setting it up according to documentation does not work. Mine fails with "Cannot find User with name xxx".
Sign in to comment