@@ -38,6 +38,7 @@ internal KuduApi(InstanceName instance, IAzure azure, ILogger logger)
3838 IFunctionApp webFunctionApp ;
3939 try
4040 {
41+ logger . WriteVerbose ( $ "Retrieving Kudu publish credentials for { instance . PlainName } .") ;
4142 webFunctionApp = await azure . AppServices . FunctionApps . GetByResourceGroupAsync ( rg , fn , cancellationToken ) ;
4243 }
4344 catch ( Exception )
@@ -52,6 +53,11 @@ internal KuduApi(InstanceName instance, IAzure azure, ILogger logger)
5253
5354 lastPublishCredentials = ( username , password ) ;
5455 lastPublishCredentialsInstance = instance . PlainName ;
56+ logger . WriteVerbose ( $ "Kudu publish credentials for { instance . PlainName } cached.") ;
57+ }
58+ else
59+ {
60+ logger . WriteVerbose ( $ "Using cached Kudu publish credentials for { instance . PlainName } .") ;
5561 }
5662
5763 return lastPublishCredentials ;
@@ -115,13 +121,15 @@ internal async Task<string> ReadApplicationLogAsync(string functionName, int log
115121 } ;
116122 for ( int attempt = 0 ; attempt < delay . Length ; attempt ++ )
117123 {
124+ logger . WriteVerbose ( $ "Listing attempt #{ attempt + 1 } )") ;
118125 using var listingRequest = await GetRequestAsync ( HttpMethod . Get , $ "{ FunctionLogPath } /{ functionName } /", cancellationToken ) ;
119126 var listingResponse = await client . SendAsync ( listingRequest , cancellationToken ) ;
120127 var listingStream = await listingResponse . Content . ReadAsStreamAsync ( cancellationToken ) ;
121128 if ( listingResponse . IsSuccessStatusCode )
122129 {
130+ logger . WriteVerbose ( $ "Got list of logs, deserializing response") ;
123131 listingResult = await JsonSerializer . DeserializeAsync < ListingEntry [ ] > ( listingStream , cancellationToken : cancellationToken ) ;
124- logger . WriteVerbose ( $ "Listing retrieved") ;
132+ logger . WriteVerbose ( $ "List of logs retrieved") ;
125133 break ;
126134 }
127135 else
@@ -133,24 +141,23 @@ internal async Task<string> ReadApplicationLogAsync(string functionName, int log
133141
134142 if ( listingResult is null )
135143 {
136- logger . WriteVerbose ( "No logs retrieved " ) ;
144+ logger . WriteVerbose ( "No logs available " ) ;
137145 return String . Empty ;
138146 }
139147
140148 if ( logIndex < 0 ) logIndex = listingResult . Length - 1 ;
141149 logger . WriteVerbose ( $ "Retrieving log #{ logIndex } ") ;
142150 string logName = listingResult [ logIndex ] . name ;
143- logger . WriteVerbose ( $ "Retrieving log '{ logName } '") ;
144151
145- logger . WriteVerbose ( $ "Retrieving { logName } log ") ;
152+ logger . WriteVerbose ( $ "Retrieving log ' { logName } ' ") ;
146153 using var logRequest = await GetRequestAsync ( HttpMethod . Get , $ "{ FunctionLogPath } /{ functionName } /{ logName } ", cancellationToken ) ;
147154 var logResponse = await client . SendAsync ( logRequest , cancellationToken ) ;
148- string logData = await logResponse . Content . ReadAsStringAsync ( cancellationToken ) ;
149155 if ( ! logResponse . IsSuccessStatusCode )
150156 {
151157 logger . WriteError ( $ "Cannot list { functionName } 's { logName } log: { logResponse . ReasonPhrase } ") ;
152158 return null ;
153159 }
160+ string logData = await logResponse . Content . ReadAsStringAsync ( cancellationToken ) ;
154161 logger . WriteVerbose ( $ "Log data retrieved") ;
155162 return logData ;
156163 }
0 commit comments