public async Task <DateTime?> LoadLatestScanAsync(string storageAccountName, string containerName) { IStorageBlockBlob scanInfoBlob = GetScanInfoBlobReference(storageAccountName, containerName); DateTime? latestScan = null; try { string scanInfoLine = await scanInfoBlob.DownloadTextAsync(CancellationToken.None); ScanInfo scanInfo; using (StringReader stringReader = new StringReader(scanInfoLine)) { scanInfo = (ScanInfo)_serializer.Deserialize(stringReader, typeof(ScanInfo)); } if (scanInfo != null) { latestScan = scanInfo.LatestScan; } return(latestScan); } catch (StorageException exception) { if (exception.IsNotFound()) { // we haven't saved any scanInfo yet return(null); } throw; } }
private static async Task <string> TryDownloadAsync(IStorageBlockBlob blob, CancellationToken cancellationToken) { try { return(await blob.DownloadTextAsync(cancellationToken)); } catch (StorageException exception) { if (exception.IsNotFound()) { return(null); } else { throw; } } }
private static async Task<string> TryDownloadAsync(IStorageBlockBlob blob, CancellationToken cancellationToken) { try { return await blob.DownloadTextAsync(cancellationToken); } catch (StorageException exception) { if (exception.IsNotFound()) { return null; } else { throw; } } }