cartography icon indicating copy to clipboard operation
cartography copied to clipboard

Azure log in fails because of deprecated function

Open lfservin opened this issue 2 years ago • 2 comments

Title: Cannot log into azure because of deprecated function get_azure_cli_credentials being used.

Description:

Attempts to log in fail, because get_azure_cli_credentials within azure.common.credentials has been deprecated and a more up to date azure cli refuses to connect using that function. Cartography should be using the functions (e.g. AzureDefaultCredential, AzureCliCredential) in the newer package azure.identity. Offending file is intel/azure/util/credentials.py

To Reproduce:

Install cartography on an azure cli >= 2.20

Logs:

If applicable, copy and paste your console log with the failing stack trace.

Screenshots:

image

Please complete the following information::

  • Cartography release version 0.55.0
  • Python version: 3.6.13
  • Azure core/cli 2.35.0

lfservin avatar Apr 12 '22 16:04 lfservin

@lfservin Thanks for brining this up. Would you be able to open a PR to fix this?

ramonpetgrave64 avatar Apr 13 '22 18:04 ramonpetgrave64

Hi! I tried to take a look at this, as a first issue to look at in this interesting project.

I tried to reproduce the error with azure-cli 2.35.0, but was not able to get to the error (I was able to successfully sync)

Here is the command I ran (after setting up my SPN) - with credentials passed

cartography --azure-sp-auth --azure-sync-all-subscriptions --azure-tenant-id ${AZURE_TENANT_ID} --azure-client-id ${AZURE_CLIENT_ID} --azure-client-secret-env-var AZURE_CLIENT_SECRET

I am not sure if this helps, but I have ran into the auth error when I run the command above without specifying credentials cartography --azure-sp-auth --azure-sync-all-subscriptions

Here is my env information:

  • cartography (lastest master branch)
% git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
  • python and az:
$ az --version
azure-cli                         2.35.0

core                              2.35.0
telemetry                          1.0.6

Dependencies:
msal                              1.17.0
azure-mgmt-resource               20.0.0

Python location '/usr/local/Cellar/azure-cli/2.35.0/libexec/bin/python'
Extensions directory '/Users/AMK/.azure/cliextensions'

Python (Darwin) 3.10.2 (main, Feb  2 2022, 08:42:42) [Clang 13.0.0 (clang-1300.0.29.3)]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy

@lfservin would you be able to provide more info to help me reproduce the error please? Thanks!

MarwaAbdallah avatar Apr 25 '22 11:04 MarwaAbdallah