-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Azure CLI GitHub Action fails with Azure CLI 2.30.0: Could not retrieve credential from local cache for service principal #20154
Comments
SymptomGitHub Action
Root causeThe is because Azure Login still uses the old ADAL-based Azure CLI After the ADAL->MSAL migration (#19853), the latest Azure CLI is not compatible with old versions. This can be reproduced with # File: .github/workflows/workflow.yml
on: [push]
name: AzureCLISample
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure CLI script
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
set -ex
ls ~/.azure
cat ~/.azure/versionCheck.json
az --version
az account show
az group list The output shows
Workaround (no longer needed now)Change - name: Azure CLI script
uses: azure/CLI@v1
with:
azcliversion: 2.29.2 Action planWe are working with GitHub Action team to fix this issue with high priority. |
az storage blob upload
fails from GitHub Action with Azure CLI 2.30.0: Could not retrieve credential from local cache for service principal
This workaround stopped working for me today. Undoing the downgrade seems to have fixed the issue. I guess the latest |
Did you upgrade from 2.29.2 -> 2.30.0? |
I upgraded |
so the fix is - name: Deploy
uses: azure/CLI@v1
with:
azcliversion: latest or can we remove the |
azcliversion: latest is the fix, I would not recommend removing the version declaration. |
2021-11-11 UpdateAs confirmed with GitHub Action team, Azure Login now uses the latest Azure CLI 2.30.0, so the workaround from #20154 (comment) is no longer needed now. Instead, if you specify
This is simply because Azure CLI 2.30.0 is not compatible with previous versions (<2.30.0). RecommendationYou may leave Still, thanks to @abhi-markan for the explanation. |
az storage blob upload
fails from GitHub Action with Azure CLI 2.30.0: Could not retrieve credential from local cache for service principal
Describe the bug
I am using the Azure CLI Github Action to upload files to Azure Blob Storage. This worked until this morning, when
latest
became CLI 2.30.0 and uploads to Blob Storage began failing with a 404ResourceNotFound
error.To Reproduce
az ad sp create-for-rbac
that has access to your storage.This will default to using
azcliversion: latest
and the new & unexpected output is:WARNING: Skip querying account key due to failure: Could not retrieve credential from local cache for service principal asdfasdf-asdf-asdf-asdf-asdfasdfasdf. Run az login for this service principal.
ERROR: Client-Request-ID=asdfasdf-asdf-asdf-asdf-adsfasdfasdf Retry policy did not allow for a retry: Server-Timestamp=Tue, 02 Nov 2021 16:52:14 GMT, Server-Request-ID=asdfadsf-asdf-asdf-asdf-asdfasdfasdfasdf, HTTP status code=404, Exception=The specified resource does not exist. ErrorCode: ResourceNotFound<?xml version="1.0" encoding="utf-8"?><Error><Code>ResourceNotFound</Code><Message>The specified resource does not exist.RequestId:asdfasdfasdf-asdf-adsf-adsf-asdfasdfasdfadsfTime:2021-11-02T16:52:15.3159868Z</Message></Error>.
Running
az login
for the associated service principal works, but does not solve this problem.Reverting to previous release by adding
to the above fixes the issue and uploads the file as expected.
Expected behavior
The latest version of the CLI should work the same as the previous version. There are no related changes in the release notes for 2.30.0..
Environment summary
Github's own Action runners using
runs-on: ubuntu-latest
(20.04.3 LTS) along with the Azure-created actions noted above, specifically 'azure/CLI@v1' (SHA:4b58c946a0f48d82cc2b6e31c0d15a6604859554).The text was updated successfully, but these errors were encountered: