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
Hope it's useful
Top comments (9)
Thank you for the setup, it worked like a charm.
I had to figure out how to create service principal correctly but it boiled down to 3 things:
az ad sp create-for-rbac --name YourPrincipalName
For some reason, YAML formatting goes sideways when you copy the snipped so had to use Gitlab CI lint.
Thanks again, this saved me a lot of time.
Thanks for the info. Might be useful to have a look at the available docker images. The
core-tools
versions contain the azure cli and azure function core tools.Thanks! I'll update the article asap
Very useful, I have been looking for this ci/cd config file for a long time ago, thanks!
I would recommend to use a Service Principal to Login to Azure to deploy with CI/CD:
Nice! I'll update the post! Thanks!
Pardon my ignorance, I'm new to all this and have a lot to learn.
With that being said, it looks to me, like you run the
curl
command and then you try to installcurl
.If this is not correct can someone explain what is actually happening here?
Thanks for the article, it helped a lot.
Here`s my sample with update dependencies dotnet 6, nodejs 16 and azure function core tools 4
Hi, thank you for sharing.
What permissions should the service principal have?
Sorry for the long delay, but I usually add as a contributor