protected Authenticated getAuthObjFromAzureCli ( ) { try { final Azure . Configurable azureConfigurable = azureConfigure ( ) ; final Authenticated auth ; if ( isInCloudShell ( ) ) { getLog ( ) . info ( AUTH_WITH_MSI ) ; auth = azureConfigurable . authenticate ( new MSICredentials ( ) ) ; } else { getLog ( ) . info ( AUTH_WITH_AZURE_CLI ) ; auth = azureConfigurable . authenticate ( AzureCliCredentials . create ( ) ) ; } return auth ; } catch ( Exception e ) { getLog ( ) . debug ( AZURE_CLI_AUTH_FAIL ) ; getLog ( ) . debug ( e ) ; } return null ; }
Get Authenticated object using authentication file from Azure CLI 2 . 0