2

Background Information

I'm trying to ensure that no matter how many times / when I run my gilab-ci.yml file, it will consistently download and install the EXACT same Azure Function deployment environment each time. I don't want to run the script today and have Azure CLI version 2.25 and then tomorrow when we trigger the pipeline, it will install / use version 2.26.

I recently came across an article that shows how to deploy an Azure Function. It's found here: https://dev.to/alandecastros/gitlab-ci-script-to-deploy-a-azure-function-3gc4

For ease of readability, I've copied and pasted the gitlab-ci.yml code here:

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

QUESTIONS

  1. From what I can tell, it feels like the first command under the scripts section will install the latest version of the Azure CLI. Is this correct? I reviewed the https://azurecliprod.blob.core.windows.net/$root/deb_install.sh file and it seems it's adding the necessary repositories to the Debian image and then runs

    apt-get install -y azure-cli

  2. In the case of nodejs, it seems it will always install major version 12... but the sub version can change. Is this correct?

  3. How can I change this logic to control version numbers? One idea is to create my own docker image using this logic once, and then just keep reusing the custom image. I've tested it and its working.

But is there a way to install a very specific version of node? I tried to test like this:

# apt-get install curl && curl -sL https://deb.nodesource.com/setup_12.x | bash - 

I can see it's installed 12.22.1

Unpacking nodejs (12.22.1-1nodesource1) ...
Setting up nodejs (12.22.1-1nodesource1) ...

I tried to follow up and do something like this:

# apt-get install nodejs12.22.1

and also

#apt-get install node_12.22.1

But in both cases I'm getting errors that it can't find these packages.

Thanks for reading / for the help.

1

1 Answer 1

0

Both the Azure CLI and Node.js offer a bash script for installation of the tools - with the drawback of always getting the latest release (then again for the majority of users this is probably a good thing). These scripts - as you figured out - do additional things like managing the repositories and trust.

Azure CLI

Microsoft offers a documentation on how to pin to a version: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt#install-specific-version In essence, you have to manually trust the signing key and add the repository as would be done by the script. Afterwards you can use the regular apt-get <package>=<version> syntax to specify a version.

Node.js

In case of Node, they are at least offering different scripts for each major release. But otherwise, it seems to be a bit more involved as is evident from https://github.com/nodesource/distributions/issues/33. I haven't tried the proposed workarounds from there as I personally am not interested in pinning Node.js to a minor release.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.