@@ -261,39 +261,37 @@ private string GetToken(string decodedPath)
261
261
/// <returns></returns>
262
262
private string [ ] GetContainerSasUris ( )
263
263
{
264
- if ( tokens == null )
265
- {
266
- tokens = new string [ 3 ] ;
267
- containerAddresses = new string [ 3 ] ;
264
+ // We need to refresh the tokens every time or they will become invalid.
265
+ tokens = new string [ 3 ] ;
266
+ containerAddresses = new string [ 3 ] ;
268
267
269
- string accountName = _configuration . GetSection ( "StorageAccountName" ) ? . Value ;
270
- string accountKey = _configuration . GetSection ( "StorageAccountKey" ) ? . Value ;
268
+ string accountName = _configuration . GetSection ( "StorageAccountName" ) ? . Value ;
269
+ string accountKey = _configuration . GetSection ( "StorageAccountKey" ) ? . Value ;
271
270
272
- SharedAccessBlobPolicy adHocPolicy = new SharedAccessBlobPolicy ( )
273
- {
274
- SharedAccessExpiryTime = DateTime . UtcNow . AddHours ( 24 ) ,
275
- Permissions = SharedAccessBlobPermissions . Read
276
- } ;
271
+ SharedAccessBlobPolicy adHocPolicy = new SharedAccessBlobPolicy ( )
272
+ {
273
+ SharedAccessExpiryTime = DateTime . UtcNow . AddHours ( 24 ) ,
274
+ Permissions = SharedAccessBlobPermissions . Read
275
+ } ;
277
276
278
- containerAddresses [ 0 ] = _configuration . GetSection ( "StorageContainerAddress" ) ? . Value . ToLower ( ) ;
279
- CloudBlobContainer container = new CloudBlobContainer ( new Uri ( containerAddresses [ 0 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
280
- tokens [ 0 ] = container . GetSharedAccessSignature ( adHocPolicy , null ) ;
277
+ containerAddresses [ 0 ] = _configuration . GetSection ( "StorageContainerAddress" ) ? . Value . ToLower ( ) ;
278
+ CloudBlobContainer container = new CloudBlobContainer ( new Uri ( containerAddresses [ 0 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
279
+ tokens [ 0 ] = container . GetSharedAccessSignature ( adHocPolicy , null ) ;
281
280
282
- // Get token for second indexer data source
283
- containerAddresses [ 1 ] = _configuration . GetSection ( "StorageContainerAddress2" ) ? . Value . ToLower ( ) ;
284
- if ( ! String . Equals ( containerAddresses [ 1 ] , defaultContainerUriValue ) )
285
- {
286
- CloudBlobContainer container2 = new CloudBlobContainer ( new Uri ( containerAddresses [ 1 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
287
- tokens [ 1 ] = container2 . GetSharedAccessSignature ( adHocPolicy , null ) ;
288
- }
281
+ // Get token for second indexer data source
282
+ containerAddresses [ 1 ] = _configuration . GetSection ( "StorageContainerAddress2" ) ? . Value . ToLower ( ) ;
283
+ if ( ! String . Equals ( containerAddresses [ 1 ] , defaultContainerUriValue ) )
284
+ {
285
+ CloudBlobContainer container2 = new CloudBlobContainer ( new Uri ( containerAddresses [ 1 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
286
+ tokens [ 1 ] = container2 . GetSharedAccessSignature ( adHocPolicy , null ) ;
287
+ }
289
288
290
- // Get token for third indexer data source
291
- containerAddresses [ 2 ] = _configuration . GetSection ( "StorageContainerAddress3" ) ? . Value . ToLower ( ) ;
292
- if ( ! String . Equals ( containerAddresses [ 2 ] , defaultContainerUriValue ) )
293
- {
294
- CloudBlobContainer container3 = new CloudBlobContainer ( new Uri ( containerAddresses [ 2 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
295
- tokens [ 2 ] = container3 . GetSharedAccessSignature ( adHocPolicy , null ) ;
296
- }
289
+ // Get token for third indexer data source
290
+ containerAddresses [ 2 ] = _configuration . GetSection ( "StorageContainerAddress3" ) ? . Value . ToLower ( ) ;
291
+ if ( ! String . Equals ( containerAddresses [ 2 ] , defaultContainerUriValue ) )
292
+ {
293
+ CloudBlobContainer container3 = new CloudBlobContainer ( new Uri ( containerAddresses [ 2 ] ) , new StorageCredentials ( accountName , accountKey ) ) ;
294
+ tokens [ 2 ] = container3 . GetSharedAccessSignature ( adHocPolicy , null ) ;
297
295
}
298
296
299
297
return tokens ;
0 commit comments