Gitlab CI script to deploy a Azure Function

alandecastros

Alan Castro

Posted on April 24, 2020

Gitlab CI script to deploy a Azure Function

Here is the .gitlab-ci.yml that I use to deploy my .NET Core 3.1 azure functions in Gitlab CI/CD.

Variables that I use in the scripts:

  • $APPLICATION_ID
  • $APPLICATION_SECRET
  • $TENANT_ID
  • $FUNCTION_APP your function app's name in azure
stages:
  - deploy

deploy:
  stage: deploy
  image: mcr.microsoft.com/dotnet/core/sdk:3.1
  script:
    - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
    - apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash -
    - apt-get install nodejs
    - npm install -g azure-functions-core-tools@3 --unsafe-perm true
    - az login --service-principal -u $APPLICATION_ID -p $APPLICATION_SECRET --tenant $TENANT_ID
    - func azure functionapp publish $FUNCTION_APP --csharp
  only:
    - master
Enter fullscreen mode Exit fullscreen mode

Hope it's useful

💖 💪 🙅 🚩
alandecastros
Alan Castro

Posted on April 24, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related