public static byte[] GetBlobMd5Hash(this CloudPageBlob blob) { blob.FetchAttributesAsync().ConfigureAwait(false).GetAwaiter().GetResult(); return(String.IsNullOrEmpty(blob.Properties.ContentMD5) ? null : Convert.FromBase64String(blob.Properties.ContentMD5)); }
private async Task ReadBlobMetadata(CloudPageBlob pageBlob) { await pageBlob.FetchAttributesAsync(); var metadata = AddMetadata(pageBlob); var nullValue = float.NaN; var nullValueParsed = metadata.ContainsKey("nullvalue") && float.TryParse(metadata["nullvalue"], NumberStyles.Any, CultureInfo.InvariantCulture, out nullValue); var dataset = new Dataset { BlobName = pageBlob.Name, MinX = ParseHeaderDouble(metadata["minx"]), MaxX = ParseHeaderDouble(metadata["maxx"]), MinY = ParseHeaderDouble(metadata["miny"]), MaxY = ParseHeaderDouble(metadata["maxy"]), Resolution = ParseHeaderDouble(metadata["resolution"]), RowLength = int.Parse(metadata["rowlength"]), ColumnLength = int.Parse(metadata["columnlength"]), HeaderOffset = int.Parse(metadata["headeroffset"]), ValueLength = int.Parse(metadata["valuelength"]), Crs = metadata.ContainsKey("crs") && metadata["crs"] != "WGS-84" ? int.Parse(metadata["crs"]) : 0, NullValue = nullValueParsed ? nullValue : float.NaN }; Files.Add(dataset); PageBlobs[dataset.BlobName] = pageBlob; }
public override void SetParameters(object parameters) { var jParameters = parameters as JObject; if (jParameters == null) { throw new ArgumentException("Expecting JObject parameters"); } var settings = jParameters.ToObject <PageBlobSettings>(); var client = new CloudBlobClient( new Uri(string.Format("https://{0}.blob.core.windows.net/", settings.AccountName)), new StorageCredentials(settings.AccountName, settings.AccountKey)); var container = client.GetContainerReference(settings.ContainerName.ToLower()); container.CreateIfNotExistsAsync().Wait(); cloudBlob = container.GetPageBlobReference(settings.BlobName); if (!cloudBlob.ExistsAsync().Result) { cloudBlob.CreateAsync(settings.BlobSizeGB * 1024L * 1024L * 1024L).Wait(); } cloudBlob.FetchAttributesAsync().Wait(); }
public static byte[] GetBlobMd5Hash(this CloudPageBlob blob, BlobRequestOptions requestOptions) { blob.FetchAttributesAsync(new AccessCondition(), requestOptions, operationContext: null) .ConfigureAwait(false).GetAwaiter().GetResult(); return(String.IsNullOrEmpty(blob.Properties.ContentMD5) ? null : Convert.FromBase64String(blob.Properties.ContentMD5)); }
private IEnumerable <IndexRange> GetPageRanges() { pageBlob.FetchAttributesAsync(new AccessCondition(), blobRequestOptions, operationContext: null) .ConfigureAwait(false).GetAwaiter().GetResult(); IEnumerable <PageRange> pageRanges = pageBlob.GetPageRangesAsync(null, null, new AccessCondition(), blobRequestOptions, operationContext: null) .ConfigureAwait(false).GetAwaiter().GetResult(); pageRanges = pageRanges.OrderBy(range => range.StartOffset); return(pageRanges.Select(pr => new IndexRange(pr.StartOffset, pr.EndOffset))); }
protected async Task <BlobProperties> GetPropertiesAsync(CloudPageBlob pageBlob, CancellationToken cancellationToken) { if (pageBlob.Properties == null || pageBlob.Properties.Length < 0) { await pageBlob.FetchAttributesAsync(CreateAccessCondition(pageBlob), this.RequestOptions, this.OperationContext, cancellationToken); } return(pageBlob.Properties); }
/// <summary> /// Start copy using transfer mangager by source uri /// </summary> /// <param name="uri">source uri</param> /// <param name="destContainer">Destination CloudBlobContainer object</param> /// <param name="destBlobName">Destination blob name</param> /// <returns>Destination CloudBlob object</returns> private async Task StartCopyAsync(long taskId, IStorageBlobManagement destChannel, Uri uri, CloudBlobContainer destContainer, string destBlobName) { NameUtil.ValidateContainerName(destContainer.Name); NameUtil.ValidateBlobName(destBlobName); CloudPageBlob sourceBlob = new CloudPageBlob(uri); //try //{ await sourceBlob.FetchAttributesAsync(null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken); VerifyIncrementalCopySourceBlob(sourceBlob); //} //catch (StorageException) //{ // //The source blob don't have read permission // //We should no block the copy in this case, //} CloudPageBlob destBlob = GetDestBlob(destChannel, destContainer.Name, destBlobName); await this.StartCopyFromUri(taskId, destChannel, uri, destBlob); }
/// <inheritdoc /> public Task FetchAttributesAsync(CancellationToken cancellationToken) { return(_sdk.FetchAttributesAsync(accessCondition: null, options: null, operationContext: null, cancellationToken: cancellationToken)); }
/// <inheritdoc /> public Task FetchAttributesAsync(CancellationToken cancellationToken) { return(_sdk.FetchAttributesAsync(cancellationToken)); }