Пример #1
1
 private static async void callback(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     var reb = (RichEditBox)d;
     Uri bloburi = new Uri((string)e.NewValue);
     CloudBlockBlob cBlob = new CloudBlockBlob(bloburi);
     var blobstr = await cBlob.DownloadTextAsync();
     reb.Document.SetText(TextSetOptions.FormatRtf, blobstr);
 }
        /// <summary>
        /// Loads the blob text content.
        /// </summary>
        /// <param name="blob">Documentation article blob.</param>
        /// <returns>The blob content as an HTML-encoded string.</returns>
        private IHtmlString GetContent(CloudBlockBlob blob)
        {
            var contents = blob.DownloadTextAsync().Result;

            return new HtmlString(contents);
        }
Пример #3
0
        public async Task TestBlobAttributesEncryptionAsync()
        {
            CloudBlobContainer container = GetRandomContainerReference();

            try
            {
                await container.CreateIfNotExistsAsync();

                CloudBlockBlob blob = container.GetBlockBlobReference(BlobTestBase.GetRandomContainerName());
                await blob.UploadTextAsync("test");

                await blob.FetchAttributesAsync();

                Assert.IsTrue(blob.Properties.IsServerEncrypted);

                CloudBlockBlob testBlob = container.GetBlockBlobReference(blob.Name);
                await testBlob.DownloadTextAsync();

                Assert.IsTrue(testBlob.Properties.IsServerEncrypted);
            }
            finally
            {
                container.DeleteIfExistsAsync().Wait();
            }
        }
Пример #4
0
        public static async Task<string> WaitForBlobAndGetStringAsync(CloudBlockBlob blob)
        {
            await WaitForBlobAsync(blob);

            string result = await blob.DownloadTextAsync(Encoding.UTF8,
                null, new BlobRequestOptions(), new Microsoft.WindowsAzure.Storage.OperationContext());

            return result;
        }
        public static async Task<string> WaitForBlobAsync(CloudBlockBlob blob)
        {
            await TestHelpers.Await(() =>
            {
                return blob.Exists();
            });

            string result = await blob.DownloadTextAsync(Encoding.UTF8,
                null, new BlobRequestOptions(), new Microsoft.WindowsAzure.Storage.OperationContext());

            return result;
        }
Пример #6
0
        private async Task ProcessJob(CloudBlockBlob jobBlob, CloudBlobContainer container)
        {
            var name = await jobBlob.DownloadTextAsync();
            var result = Compliments.GetRandomCompliment(name);

            string resultBlobName = jobBlob.Name.Replace("job/", "result/");

            CloudBlockBlob resultBlob = container.GetBlockBlobReference(resultBlobName);
            await resultBlob.UploadTextAsync(result);

            jobBlob.Metadata["Status"] = "finished";
            await jobBlob.SetMetadataAsync();
        }
 private async Task<SnapshotState> GetSnapshotStateForVm(VirtualMachine vm)
 {
     var snapshotStateUri = vm.StorageProfile.OSDisk.VirtualHardDisk.Uri + ".snapshotstate";
     var storageCred = await GetStorageCredentialsForUri(snapshotStateUri);
     var blob = new CloudBlockBlob(new Uri(snapshotStateUri), storageCred);
     var snapshotState = new SnapshotState();
     if (await blob.ExistsAsync())
     {
         snapshotState = JsonConvert.DeserializeObject<SnapshotState>(await blob.DownloadTextAsync());
     }
     return snapshotState;
 }
Пример #8
0
        private static async Task<string> ConvertToCsvLineAsync(CloudBlockBlob blob)
        {
            try
            {
                var blobData = await blob.DownloadTextAsync();
                var b = JsonConvert.DeserializeObject<CarState>(blobData);

                var result = string.Format("{0},{1},{2},{3},{4},{5},{6}", blob.Name, b.LastUpdatedUtc, b.Speed, b.Latitude, b.Longitude, b.Altitude, b.Heading);
                return result;
            }
            catch (StorageException ex)
            {
                Console.Error.WriteLine("Error reading blob: {0}", ex);
                System.Environment.Exit(1);
                return default(string);
            }
        }
 private static async Task<PartitionCheckpoint> GetCheckpointAsync(CloudBlockBlob blob)
 {
     var text = await blob.DownloadTextAsync().ConfigureAwait(false);
     return JsonConvert.DeserializeObject<PartitionCheckpoint>(text);
 }