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

Login @v2 error registering cloud profile when used against AzureStack #459

Closed
mikhail-teslya opened this issue Jun 7, 2024 · 12 comments · Fixed by #466
Closed

Login @v2 error registering cloud profile when used against AzureStack #459

mikhail-teslya opened this issue Jun 7, 2024 · 12 comments · Fixed by #466
Assignees
Labels
bug Something isn't working

Comments

@mikhail-teslya
Copy link

Hello
we used @v1 for our logins to AzureStack, and it worked fine until we were hit by 447 and had to migrate to @v2. After we switched versions, the login step started failing with the below log:

Run azure/login@v2
  with:
    creds: ***
    environment: AzureStack
    enable-AzPSSession: true
    allow-no-subscriptions: false
    audience: api://AzureADTokenExchange
    auth-type: SERVICE_PRINCIPAL
  env:
    ACTIONS_ALLOW_UNSECURE_COMMANDS: true
##[debug]Reading creds in JSON...
::add-mask::***
::add-mask::***
Running Azure CLI Login.
##[debug]Azure CLI path: /usr/bin/az
##[debug]Azure CLI version used:
##[debug]azure-cli                         2.61.0
##[debug]
##[debug]core                              2.61.0
##[debug]telemetry                          1.1.0
##[debug]
##[debug]Extensions:
##[debug]azure-devops                       1.0.1
##[debug]
##[debug]Dependencies:
##[debug]msal                              1.28.0
##[debug]azure-mgmt-resource               23.1.1
##[debug]
##[debug]Python location '/opt/az/bin/python3'
##[debug]Extensions directory '/opt/az/azcliextensions'
##[debug]
##[debug]Python (Linux) 3.11.8 (main, May 16 2024, 03:47:28) [GCC 11.4.0]
##[debug]
##[debug]Legal docs and information: aka.ms/AzureCliLegal
##[debug]
##[debug]
##[debug]Your CLI is up-to-date.
##[debug]
Unregistering cloud: "azurestack" first if it exists
/usr/bin/az cloud set -n azurestack
/usr/bin/az cloud unregister -n azurestack
ERROR: The cloud 'azurestack' is not registered.
Error: Login failed with Error: The process '/usr/bin/az' failed with exit code 1. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.
##[debug]Error: The process '/usr/bin/az' failed with exit code 1
##[debug]    at ExecState._setResult (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2333:25)
##[debug]    at ExecState.CheckComplete (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2316:18)
##[debug]    at ChildProcess.<anonymous> (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2210:27)
##[debug]    at ChildProcess.emit (node:events:519:28)
##[debug]    at maybeClose (node:internal/child_process:1105:16)
##[debug]    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
ERROR: The cloud 'azurestack' is not registered.
Ignore cloud not registered error: "Error: The process '/usr/bin/az' failed with exit code 1"
Registering cloud: "azurestack" with ARM endpoint: "https://management.<hiddenhost>.domain"
/usr/bin/az cloud register -n azurestack --endpoint-resource-manager "https://management.<hiddenhost>.domain" --suffix-keyvault-dns ".vault.<hiddenhost>.domain" --suffix-storage-endpoint "<hiddenhost>.domain" --profile "2019-03-01-hybrid"
ERROR: az cloud register: '"2019-03-01-hybrid"' is not a valid value for '--profile'. Allowed values: latest, 2017-03-09-profile, 2018-03-01-hybrid, 2019-03-01-hybrid, 2020-09-01-hybrid.
Did you mean '2019-03-01-hybrid' ?

Examples from AI knowledge base:
az cloud register -n MyCloud --cloud-config @"cloud.json" ("cloud.json" supports all the endpoint and suffix options in camel case or the JSON output format from `az cloud show`. See the example content below.) *** "endpointActiveDirectory": "https://login.microsoftonline.us", "suffixAcrLoginServerEndpoint": ".azurecr.us" *** or *** "endpoints":*** "activeDirectory": "https://login.microsoftonline.us" ***, "suffixes":*** "acrLoginServerEndpoint": ".azurecr.us" *** ***
Register a cloud with a config file

https://aka.ms/cli_ref
Read more about the command in reference docs
Error: Error while trying to register cloud "azurestack"
/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2333
                error = new Error(`The process '$***this.toolPath***' failed with exit code $***this.processExitCode***`);
                        ^

Error: The process '/usr/bin/az' failed with exit code 2
    at ExecState._setResult (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2333:25)
    at ExecState.CheckComplete (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2316:18)
    at ChildProcess.<anonymous> (/home/runner/work/_actions/azure/login/v2/lib/main/index.js:2210:27)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

Node.js v20.13.1

The workflow step is as follows:

    - uses: azure/login@v2
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
        environment: "AzureStack"
        enable-AzPSSession: true

I am repeating myself, but the only difference with the previously working code is the @v2 tag after azure/login
Can we please get some help? Thanks

@mikhail-teslya mikhail-teslya added the need-to-triage Requires investigation label Jun 7, 2024
@MoChilia MoChilia self-assigned this Jun 11, 2024
@MoChilia
Copy link
Member

Hi @mikhail-teslya, it seems that the argument profile doesn't pass correctly in the workflow. Could you please try the fix-459 branch to see if it works for you?

- uses: azure/login@fix-459
      with:
        creds: ${{ secrets.AZURE_CREDENTIALS }}
        environment: "AzureStack"
        enable-AzPSSession: true

@MoChilia MoChilia added bug Something isn't working and removed need-to-triage Requires investigation labels Jun 11, 2024
@mikhail-teslya
Copy link
Author

Hi @MoChilia, thanks for the update, we'll test ASAP and get back with an update

@mikhail-teslya
Copy link
Author

Cloud is now registered, but we got another error:

Run azure/login@fix-459
  with:
    creds: ***
    environment: AzureStack
    enable-AzPSSession: true
    allow-no-subscriptions: false
    audience: api://AzureADTokenExchange
    auth-type: SERVICE_PRINCIPAL
  env:
    ACTIONS_ALLOW_UNSECURE_COMMANDS: true
##[debug]Reading creds in JSON...
::add-mask::***
::add-mask::***
Running Azure CLI Login.
##[debug]Azure CLI path: /usr/bin/az
##[debug]Azure CLI version used:
##[debug]***
##[debug]  "azure-cli": "2.61.0",
##[debug]  "azure-cli-core": "2.61.0",
##[debug]  "azure-cli-telemetry": "1.1.0",
##[debug]  "extensions": ***
##[debug]    "azure-devops": "1.0.1"
##[debug]  ***
##[debug]***
##[debug]
Unregistering cloud: "azurestack" first if it exists
/usr/bin/az cloud set -n azurestack
/usr/bin/az cloud unregister -n azurestack
ERROR: The cloud 'azurestack' is not registered.
Error: Login failed with Error: The process '/usr/bin/az' failed with exit code 1. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.
##[debug]Error: The process '/usr/bin/az' failed with exit code 1
##[debug]    at ExecState._setResult (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2333:25)
##[debug]    at ExecState.CheckComplete (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2316:18)
##[debug]    at ChildProcess.<anonymous> (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2210:27)
##[debug]    at ChildProcess.emit (node:events:519:28)
##[debug]    at maybeClose (node:internal/child_process:1105:16)
##[debug]    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
ERROR: The cloud 'azurestack' is not registered.
Ignore cloud not registered error: "Error: The process '/usr/bin/az' failed with exit code 1"
Registering cloud: "azurestack" with ARM endpoint: "https://management.<hiddenhost>.domain"
/usr/bin/az cloud register -n azurestack --endpoint-resource-manager https://management.<hiddenhost>.domain --suffix-keyvault-dns .vault.<hiddenhost>.domain --suffix-storage-endpoint .<hiddenhost>.domain --profile 2019-03-01-hybrid
Done registering cloud: "azurestack"
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Login to AzureStack with Az Powershell

@mikhail-teslya
Copy link
Author

Hello, @MoChilia do you have any news? :) Thanks

@MoChilia
Copy link
Member

@mikhail-teslya, it appears that the process exits after registering the cloud. The subsequent login commands did not execute. Actually, the error ERROR: The cloud 'azurestack' is not registered should be ignored, as

catch (error) {
core.info(`Ignore cloud not registered error: "${error}"`);
}

I will prepare a debug release for you tomorrow.

@MoChilia
Copy link
Member

@mikhail-teslya, I've removed the unregistering part. Please try azure/login@fix-459 again, thanks!

@mikhail-teslya
Copy link
Author

@MoChilia an error again, the output is line-to-line the same as the previous one

@mikhail-teslya
Copy link
Author

mikhail-teslya commented Jun 19, 2024

@MoChilia an update: it appeared it is slightly different, but after examining it twice I still see the error is happening exactly at the same place. Just in case I will leave a new log below:

Run azure/login@fix-459
  with:
    creds: ***
    environment: AzureStack
    enable-AzPSSession: true
    allow-no-subscriptions: false
    audience: api://AzureADTokenExchange
    auth-type: SERVICE_PRINCIPAL
  env:
    ACTIONS_ALLOW_UNSECURE_COMMANDS: true
##[debug]Reading creds in JSON...
::add-mask::***
::add-mask::***
Running Azure CLI Login.
##[debug]Azure CLI path: /usr/bin/az
##[debug]Azure CLI version used:
##[debug]***
##[debug]  "azure-cli": "2.61.0",
##[debug]  "azure-cli-core": "2.61.0",
##[debug]  "azure-cli-telemetry": "1.1.0",
##[debug]  "extensions": ***
##[debug]    "azure-devops": "1.0.1"
##[debug]  ***
##[debug]***
##[debug]
Registering cloud: "azurestack" with ARM endpoint: "https://management..<hiddenhost>.domain"
/usr/bin/az cloud register -n azurestack --endpoint-resource-manager https://management..<hiddenhost>.domain --suffix-keyvault-dns .vault..<hiddenhost>.domain --suffix-storage-endpoint .<hiddenhost>.domain --profile 2019-03-01-hybrid
/usr/bin/az cloud set -n azurestack
ERROR: The cloud 'azurestack' is not registered.
Error: Login failed with Error: The process '/usr/bin/az' failed with exit code 1. Double check if the 'auth-type' is correct. Refer to https://github.com/Azure/login#readme for more information.
##[debug]Error: The process '/usr/bin/az' failed with exit code 1
##[debug]    at ExecState._setResult (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2333:25)
##[debug]    at ExecState.CheckComplete (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2316:18)
##[debug]    at ChildProcess.<anonymous> (/home/runner/work/_actions/azure/login/fix-459/lib/main/index.js:2210:27)
##[debug]    at ChildProcess.emit (node:events:519:28)
##[debug]    at maybeClose (node:internal/child_process:1105:16)
##[debug]    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
Done registering cloud: "azurestack"
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Login to AzureStack with Az Powershell

@MoChilia
Copy link
Member

@mikhail-teslya, I've updated the branch azure/login@fix-459 now. It appears that the az cloud set executed before az cloud register. Could you please try again?
If you encounter any issues again, feel free to contact me via Teams. You can find my email on the profile. Since I don't have access to an Azure Stack environment, I need your assistance with testing this. Thanks!

@mikhail-teslya
Copy link
Author

@MoChilia this time it worked

@MoChilia
Copy link
Member

MoChilia commented Jun 20, 2024

@mikhail-teslya, great, thanks for testing this! I've created a pull request: #466 for this bug fix and will inform when it's officially released.

@mikhail-teslya
Copy link
Author

@MoChilia thanks for your efforts! Looking forward to the new version :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants