@@ -55,6 +55,7 @@ private void ExecuteCore()
5555 }
5656
5757 DefaultAzureCredential credential ;
58+ DefaultAzureCredentialOptions credentialoptions ;
5859
5960 if ( string . IsNullOrEmpty ( ClientId ) && ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "ARM_CLIENT_ID" ) ) )
6061 {
@@ -64,21 +65,46 @@ private void ExecuteCore()
6465
6566 if ( string . IsNullOrEmpty ( ClientId ) )
6667 {
67- credential = new DefaultAzureCredential ( ) ;
68+ credentialoptions = new DefaultAzureCredentialOptions
69+ {
70+ Diagnostics =
71+ {
72+ LoggedHeaderNames = { "x-ms-request-id" } ,
73+ LoggedQueryParameters = { "api-version" } ,
74+ IsAccountIdentifierLoggingEnabled = true
75+ }
76+ } ;
6877 Log . LogMessage ( $ "Trying to use managed identity without default identity") ;
6978 }
7079 else
7180 {
72- credential = new DefaultAzureCredential ( new DefaultAzureCredentialOptions { ManagedIdentityClientId = ClientId } ) ;
81+ credentialoptions = new DefaultAzureCredentialOptions
82+ {
83+ Diagnostics =
84+ {
85+ LoggedHeaderNames = { "x-ms-request-id" } ,
86+ LoggedQueryParameters = { "api-version" } ,
87+ IsAccountIdentifierLoggingEnabled = true
88+ } ,
89+ ManagedIdentityClientId = clientId } ;
7390 Log . LogMessage ( $ "Trying to use managed identity with client id: { ClientId } ") ;
7491 }
7592
93+ credential = new DefaultAzureCredential ( credentialoptions ) ;
94+
7695 BlobServiceClient blobServiceClient = new (
7796 new Uri ( StorageAccount ) ,
7897 credential ) ;
7998
8099 var containerClient = blobServiceClient . GetBlobContainerClient ( BlobContainer ) ;
81- Pageable < BlobItem > blobs = containerClient . GetBlobs ( prefix : RepoName + "/" ) ;
100+ try
101+ {
102+ Pageable < BlobItem > blobs = containerClient . GetBlobs ( prefix : RepoName + "/" ) ;
103+ }
104+ catch ( AuthenticationFailedException e )
105+ {
106+ Fatal ( $ "*** BLOB ENUMERATION FAILED: { e . Message } ") ;
107+ }
82108 BlobItem newest = blobs . OrderByDescending ( b => b . Name ) . FirstOrDefault ( ) ;
83109 if ( newest == null )
84110 {
@@ -89,7 +115,14 @@ private void ExecuteCore()
89115 BlobClient blobClient = containerClient . GetBlobClient ( newest . Name ) ;
90116 var loggableUrl = new UriBuilder ( blobClient . Uri ) { Fragment = "" , Query = "" } ;
91117 Log . LogMessage ( $ "Extracting { loggableUrl } to { OutputDirectory } ") ;
92- using Stream fileStream = blobClient . OpenRead ( ) ;
118+ try
119+ {
120+ using Stream fileStream = blobClient . OpenRead ( ) ;
121+ }
122+ catch ( AuthenticationFailedException e )
123+ {
124+ Fatal ( $ "*** STREAM READ FAILED: { e . Message } ") ;
125+ }
93126 using var input = new GZipInputStream ( fileStream ) ;
94127 using var archive = TarArchive . CreateInputTarArchive ( input , Encoding . UTF8 ) ;
95128 archive . ExtractContents ( OutputDirectory , true ) ; // would like this to be false, but SharpZipLib has a bug in 1.3.3
0 commit comments