@@ -289,9 +289,9 @@ public static async Task<string> GetAccessTokenAsync()
289
289
var url = IMDS_BASE_URL + IMDS_TOKEN_PATH ;
290
290
var request = new System . Net . Http . HttpRequestMessage ( System . Net . Http . HttpMethod . Put , url ) ;
291
291
request . Headers . Add ( "X-aws-ec2-metadata-token-ttl-seconds" , "60" ) ;
292
- var response = await Client . SendAsync ( request ) ;
292
+ var response = await Client . SendAsync ( request ) . ConfigureAwait ( false ) ;
293
293
response . EnsureSuccessStatusCode ( ) ;
294
- return await response . Content . ReadAsStringAsync ( ) ;
294
+ return await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
295
295
}
296
296
297
297
public static async Task < bool > IsIMDSv1 ( )
@@ -302,7 +302,7 @@ public static async Task<bool> IsIMDSv1()
302
302
}
303
303
try
304
304
{
305
- var response = await Client . GetAsync ( IMDSV1_BASE_URL ) ;
305
+ var response = await Client . GetAsync ( IMDSV1_BASE_URL ) . ConfigureAwait ( false ) ;
306
306
response . EnsureSuccessStatusCode ( ) ; // Check if the request succeeds
307
307
_isIMDSv1 = true ; // Cache the result
308
308
return true ; // IMDSv1 endpoint exists, so assume it's IMDSv1
@@ -327,9 +327,9 @@ public static async Task<string> GetEC2InstanceId()
327
327
var token = await GetAccessTokenAsync ( ) ;
328
328
request . Headers . Add ( "X-aws-ec2-metadata-token" , token ) ;
329
329
}
330
- var response = await Client . SendAsync ( request ) ;
330
+ var response = await Client . SendAsync ( request ) . ConfigureAwait ( false ) ;
331
331
response . EnsureSuccessStatusCode ( ) ;
332
- string id = await response . Content . ReadAsStringAsync ( ) ;
332
+ string id = await response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
333
333
r = string . IsNullOrWhiteSpace ( id ) ? null : id ;
334
334
}
335
335
catch ( Exception ex ) // if not in aws this will timeout
0 commit comments