@@ -55,6 +55,7 @@ private void ExecuteCore()
55
55
}
56
56
57
57
DefaultAzureCredential credential ;
58
+ DefaultAzureCredentialOptions credentialoptions ;
58
59
59
60
if ( string . IsNullOrEmpty ( ClientId ) && ! string . IsNullOrEmpty ( Environment . GetEnvironmentVariable ( "ARM_CLIENT_ID" ) ) )
60
61
{
@@ -64,21 +65,46 @@ private void ExecuteCore()
64
65
65
66
if ( string . IsNullOrEmpty ( ClientId ) )
66
67
{
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
+ } ;
68
77
Log . LogMessage ( $ "Trying to use managed identity without default identity") ;
69
78
}
70
79
else
71
80
{
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 } ;
73
90
Log . LogMessage ( $ "Trying to use managed identity with client id: { ClientId } ") ;
74
91
}
75
92
93
+ credential = new DefaultAzureCredential ( credentialoptions ) ;
94
+
76
95
BlobServiceClient blobServiceClient = new (
77
96
new Uri ( StorageAccount ) ,
78
97
credential ) ;
79
98
80
99
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
+ }
82
108
BlobItem newest = blobs . OrderByDescending ( b => b . Name ) . FirstOrDefault ( ) ;
83
109
if ( newest == null )
84
110
{
@@ -89,7 +115,14 @@ private void ExecuteCore()
89
115
BlobClient blobClient = containerClient . GetBlobClient ( newest . Name ) ;
90
116
var loggableUrl = new UriBuilder ( blobClient . Uri ) { Fragment = "" , Query = "" } ;
91
117
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
+ }
93
126
using var input = new GZipInputStream ( fileStream ) ;
94
127
using var archive = TarArchive . CreateInputTarArchive ( input , Encoding . UTF8 ) ;
95
128
archive . ExtractContents ( OutputDirectory , true ) ; // would like this to be false, but SharpZipLib has a bug in 1.3.3
0 commit comments