CLI requiring set account command
Closed this issue · 4 comments
Each attempt to run any commands with the azure/cli ends with the same error:
Starting script execution via docker image mcr.microsoft.com/azure-cli:2.0.72
ERROR: Please run 'az account set' to select active account.
Error: Error: az cli script failed.
The same commands were working as of Nov 8, stopped working on Nov 9 with this error. I attempted to add the following line to each of my uses of the Azure/CLI action, but the same issue persists.
az account set -s "$SUBSCRIPTION"
Running on: ubuntu-latest
here is the full command
- name: Set version info in staging slot
uses: azure/CLI@v1
with:
azcliversion: 2.0.72
inlineScript: |
az account set -s "$SUBSCRIPTION"
az functionapp config appsettings set --slot staging --output none --name ${{ env.AZURE_FUNCTIONAPP_NAME }} --resource-group my-resource-group --settings "VERSION=${{ needs.build_and_deploy.outputs.RELEASE_VERSION }}"
Hi @rue-kcarlton Can you please confirm the version of azure cli on the agent?
- Is it 2.30.0?
- Also are you using azure/login before azure/cli?
If yes then there is a breaking change from version 2.29.2 to 2.30.0, so all the workflows using azure/login on GitHub Hosted Agent
will fail with any version below 2.30.0.
In order to fix you problem either set azcliversion
to 2.30.0
- name: Upload to blob storage
uses: azure/CLI@v1
with:
azcliversion: 2.30.0
inlineScript: |
az storage blob upload-batch ...
or leave it to default
- name: Upload to blob storage
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch ...
In default case, action will automatically choose azcliversion which is already installed on the agent so that there will be no mismatch, even if we have any further breaking changes in future.
🤦 I kept reading my azcliversion
as 2.79.0 instead of 2.0.79. That was the problem. Thank you for not making fun of my oversight.
This solved it for me. I use azure/login, then azure/cli. I changed the azure/cli azureversion to 2.30.0 and the build works now. Thanks.
Glad to help 😁