简体   繁体   中英

Deploy Azure Functions in netcore 3 with bitbucket pipeline

I've been going around in circles trying to understand why the following pipeline finishes successfully on bitbucket but there is no available function on Azure side.

image: mcr.microsoft.com/dotnet/sdk:3.1

pipelines:
  custom:
   deployment-to-prod:
    - step:
        name: 'Build function zip'
        caches:
            - dotnetcore
        script:
           - dotnet restore
           - mkdir ./Package
           - dotnet build /p:DeployOnBuild=true /p:DeployTarget=Package;CreatePackageOnPublish=true
           - dotnet publish $PROJECT_NAME --configuration Release -o ./Package
           - apt-get update
           - apt-get install zip -y
           - zip -r function.zip ./Package
        artifacts:
            - function.zip
    - step:
        name: 'Deploy zip to Sandbox'
        #deployment: production
        #trigger: 'manual'
        script:
          - pipe: microsoft/azure-functions-deploy:1.0.2
            variables:
              AZURE_APP_ID: $AZURE_APP_ID
              AZURE_PASSWORD: $AZURE_PASSWORD
              AZURE_TENANT_ID: $AZURE_TENANT_ID
              FUNCTION_APP_NAME: $FUNCTION_NAME
              ZIP_FILE: function.zip
              # DEBUG: '<boolean>' # Optional

I guess the issue must be with the zip which is been generated from the publishing but can't figure out. Can somebody assist me?

Thank you for your help

note: I tried only build without publishing too but the results are the same. The zip file generated has the following file hierarchy./Package >>.netcoreapp3.1/ >> Publish

To deploy the azure function app deployment source config-zip write the below step with CLI commands

- step:
    name: Deploy on Azure
    image: mcr.microsoft.com/azure-cli:latest
    script:
    - az login --service-principal --username ${AZURE_APP_ID} --password ${AZURE_PASSOWRD} --tenant ${AZURE_TENANT_ID}
    - az functionapp deployment source config-zip -g ${RESOURCE_GROUP_NAME} -n 'functioAppName' --src 'function.zip' --build-remote

Also you can write step by using ZIP Deploy

To check the deprecated image of CLI check this CLI

Click the Deprecated Image for further information.

在此处输入图像描述

You can also use atlassian version of Pipe .

Also Check the SO for same discussions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM