Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support azcliversion #164

Closed
jiasli opened this issue Nov 3, 2021 · 13 comments
Closed

Support azcliversion #164

jiasli opened this issue Nov 3, 2021 · 13 comments
Labels
product enhancement New feature or request

Comments

@jiasli
Copy link
Member

jiasli commented Nov 3, 2021

Azure CLI Action supports azcliversion:

https://github.com/Azure/cli/blob/master/src/main.ts#L25

let azcliversion: string = core.getInput('azcliversion', { required: true }).trim().toLowerCase();

In case of Azure CLI compatibility issue or bug, it is possible to revert to old versions of Azure CLI.

But, Azure Login doesn't have azcliversion: https://github.com/Azure/login/blob/master/src/main.ts

In case of az login compatibility issue or bug, there is no way for Azure Login to recover.

Related issues:

@restfulhead
Copy link

restfulhead commented Nov 16, 2021

Yes, I hope this request gets prioritized. I came here from Azure/cli#56 (comment) where builds started to fail one day without any changes on our end. We need to be able to pin the version to guarantee stable builds...

@Menci
Copy link

Menci commented Nov 27, 2021

There's a workaround that invokes az login in azure/CLI action:

    - uses: azure/CLI@v1
      with:
        azcliversion: 2.28.0
        inlineScript: |
          AZ_PYTHON_PARSE_CODE='import sys, re; s = "".join(sys.stdin.readlines()); data = {a: b for a, b in [x.split(":") for x in re.sub("[\s\"]", "", s)[1:-1].split(",")]}'

          AZ_CLIENT_ID="$(python3 -c "$AZ_PYTHON_PARSE_CODE; print(data['clientId'])" <<< "$AZ_CRED")"
          AZ_CLIENT_SECRET="$(python3 -c "$AZ_PYTHON_PARSE_CODE; print(data['clientSecret'])" <<< "$AZ_CRED")"
          AZ_SUBSCRIPTION_ID="$(python3 -c "$AZ_PYTHON_PARSE_CODE; print(data['subscriptionId'])" <<< "$AZ_CRED")"
          AZ_TENANT_ID="$(python3 -c "$AZ_PYTHON_PARSE_CODE; print(data['tenantId'])" <<< "$AZ_CRED")"

          az login --service-principal -u "$AZ_CLIENT_ID" -p "$AZ_CLIENT_SECRET" --tenant "$AZ_TENANT_ID"
          az account set --subscription "$AZ_SUBSCRIPTION_ID"
      env:
        AZ_CRED: ${{ secrets.creds }}

You can also use it in a composite action like this.

Parsing creds with Python since passing it to a composite action will lose double quotes ({"a": "b"} turns to {a: b}) in the string.

@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle Inactive for 14 days label Dec 11, 2021
@cperfect
Copy link

Also would resolve microsoft/azure-container-apps#28

@github-actions github-actions bot removed the idle Inactive for 14 days label Jan 22, 2022
@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle Inactive for 14 days label Feb 5, 2022
@NissesSenap
Copy link

Ping

@github-actions github-actions bot removed the idle Inactive for 14 days label Feb 5, 2022
@github-actions
Copy link

This issue is idle because it has been open for 14 days with no activity.

@github-actions github-actions bot added the idle Inactive for 14 days label Feb 19, 2022
@NissesSenap
Copy link

Pong

@github-actions github-actions bot removed the idle Inactive for 14 days label Feb 19, 2022
@BALAGA-GAYATRI
Copy link
Contributor

Here the issue is when there is a compact issue that arises when a workflow uses both CLI and azure login actions. So if the cli latest is incompatible with the cli from the runner, workflows might fail. In order to avoid this issue, CLI action now implements a new strategy that checks for the runner CLI version and defaults to it unless an explicit version is provided in azcliversion. So that would solve the above concern.
More details - https://github.com/azure/cli#github-action-for-azure-cli

@NissesSenap
Copy link

NissesSenap commented Feb 21, 2022

@BALAGA-GAYATRI I'm going to be rather honest in this but i don't understand the solution.

Using the Azure CLI GitHub action is a know workaround and something that all of us had to apply when Microsoft did this breaking change without releasing a major version. See:
#164 (comment)

We don't want to use this workaround, the whole point of this GitHub action is to login.

I read though the docs in detail that you point to and I can't see any documentation about this magic that you are taking about.

If you have some magic in this GitHub action please document it in this action and don't point to the Azure CLI GitHub action. Also please provide a link to the PR where this was implemented. So we have a chance of understanding how this works.

@BALAGA-GAYATRI
Copy link
Contributor

Hey @NissesSenap

Main reason for raising the issue:

So when az-cli came up with a new version using MSAL removing ADAL, it basically changed the way credentials are stored in the machine. So at that time users having both these actions (i.e, azure/login and azure/cli) in their workflows faced an issue because previously azcliversion variable defaulted to latest which is latest MSAL and our login action used the cli which is present in the runner. This caused the compat issue. Now azure/cli action's azcliversion defaults to the runner cli if not specified. This will prevent the compat issues in future. Coming to azure/login action , the current design doesn't include this azcliversion implementation and may be implemented in future but can't promise to have this any time soon. Hope this answered your question. Thanks.

@NissesSenap
Copy link

I know, i have spent allot of time working around this issue.
Isn't the whole point of this issue that we want support for azcliversion? So the next time Azure decide to do a breaking change without making major release we can work around it by defining the azcliversion so we don't have to use the ugly workaround and actually be able to use the login GitHub action.

To me it makes sense to keep this issue open until the issue is solved. How else will keep track of it?

@NissesSenap
Copy link

Another option could be that you say that it will never be implemented and then we know that at least :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants