Azure / cli

Automate your GitHub workflows using Azure CLI scripts
MIT License
133 stars 54 forks source link

Unable to use `az confcom` extention as it shows `docker process was not found` #156

Closed cYKatherine closed 3 months ago

cYKatherine commented 3 months ago

Hello, I tried to use this action to run az confcom acipolicygen --debug --approve-wildcards -a test.json --print-policy in inlineScript but it showed warning cli.azext_confcom.custom: The docker process was not found. Please start Docker.

I tried to check if docker was started using systemctl | grep running but systemctl wasn't installed in the docker image (I assume?).

Also from this article: https://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ I saw that it is not recommended to run docker inside docker, so I'm wondering does that mean there is no Docker running in this github action? Does that mean I can't run az confcom with this action? Is there any way to bypass this issue?

Thank you so much!

MoChilia commented 3 months ago

Hi @cYKatherine, as you mentioned, running docker inside docker is not recommended, so the azure/cli action does not support running docker commands inside. A current solution is to run these commands directly in bash. We may consider an enhancement to enable users to run Docker commands within azure/cli.

MoChilia commented 3 months ago

Similar issue to https://github.com/Azure/cli/issues/152.

cYKatherine commented 3 months ago

Hello @MoChilia , thank you for getting back to me.

Can I confirm it is not possible to run az confcom using this azure/cli action?

A side question is: is there any way to run a specific az version on bash? From this comment you left last year it seems that it's not possible, has anything been upgraded between now and then?

Thank you so much!

MoChilia commented 3 months ago

From the error message you provided, it appears that az confcom requires docker to start. Currently, this is not supported in the azure/cli action. Running a specific az version on bash can be a bit complex. You may refer to the downgrade scripts I have given in https://github.com/Azure/login/issues/372#issuecomment-2056289617.

cYKatherine commented 3 months ago

Thank you @MoChilia I used the instruction here: https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=apt and it worked.

For anyone who might also need this, this is how my workflow looks like:

     - name: uninstall azure-cli 
        run: |
          sudo apt-get remove -y azure-cli

      - name: install azure-cli 2.61.0
        run: |
          sudo apt-get update
          sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
          sudo mkdir -p /etc/apt/keyrings
          curl -sLS https://packages.microsoft.com/keys/microsoft.asc |
            gpg --dearmor | sudo tee /etc/apt/keyrings/microsoft.gpg > /dev/null
          sudo chmod go+r /etc/apt/keyrings/microsoft.gpg
          AZ_DIST=$(lsb_release -cs)
          echo "Types: deb
          URIs: https://packages.microsoft.com/repos/azure-cli/
          Suites: ${AZ_DIST}
          Components: main
          Architectures: $(dpkg --print-architecture)
          Signed-by: /etc/apt/keyrings/microsoft.gpg" | sudo tee /etc/apt/sources.list.d/azure-cli.sources
          sudo apt-get update
          sudo apt-get install azure-cli

          apt-cache policy azure-cli
          # Obtain the currently installed distribution
          AZ_DIST=$(lsb_release -cs)
          # Store an Azure CLI version of choice
          AZ_VER=2.61.0
          # Install a specific version
          sudo apt-get install azure-cli=${AZ_VER}-1~${AZ_DIST} --allow-downgrades

      - name: check azure-cli version
        run: |
          az --version