I am trying to deploy a hello world Azure Functions app through Azure Pipeline but it just wont deploy.
I am using azure-functions-core-tools v4.x which allows me to create a function app using func init and func new ...
Now the folder structure I got is this:
root
host.json
node_modules
package.json
src/function/helloWorld.js <-- JUST A SIMPLE HELLO WORLD FUNCTION
const { app } = require('@azure/functions');
app.http('helloWorld', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
handler: async (request, context) => {
context.log(`Http function processed request for url "${request.url}"`);
const name = request.query.get('name') || await request.text() || 'world';
return { body: `Hello, ${name}!` };
}
});
have host.json at root.
My pipeline looks like this:
steps:
- task: UseNode@1
inputs:
version: $(nodeVersion)
- task: Npm@1
displayName: "Install dependencies"
inputs:
command: "install"
- task: ArchiveFiles@2
displayName: "Archive function app"
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)" # <-- zip entire project
includeRootFolder: false
archiveType: "zip"
archiveFile: "$(Build.ArtifactStagingDirectory)/functionapp.zip"
replaceExistingArchive: true
- task: PublishBuildArtifacts@1
displayName: "Publish function app artifact"
inputs:
PathtoPublish: "$(Build.ArtifactStagingDirectory)"
ArtifactName: "functionapp"
- task: AzureFunctionApp@1
displayName: "Deploy to Azure Function App"
inputs:
azureSubscription: $(azureServiceConnection)
appType: functionAppLinux
appName: $(functionAppName)
package: "$(Build.ArtifactStagingDirectory)/functionapp.zip"
I am getting error:
App Service Application settings are already present. Package deployment using ZIP Deploy initiated. ##[error]Failed to deploy web package to App Service. ##[warning]Can't find loc string for key: KuduStackTraceURL ##[error]KuduStackTraceURL [REDACTED - DOESNT OPEN IN BROWSER ANYWAY] ##[error]Error: Error: Failed to deploy web package to App Service. Bad Gateway (CODE: 502) ##[warning]Error: Failed to update deployment history. Error: Method Not Allowed (CODE: 405) App Service Application URL: [REDACTED] Finishing: Deploy to Azure Function App
I have confirmed that Artifact is being built. All other steps in pipeline are running fine but I DONT KNOW WHY this step is not working.
As per GPT, its a folder structure issue. I got this folder structure from azure-functions-core-tools package.


