public static async Task CallBlobAdvancedSamples()
{
CloudStorageAccount storageAccount;
try
{
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
}
catch (StorageException e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
// Create service client for credentialed access to the Blob service.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = null;
ServiceProperties userServiceProperties = null;
try
{
// Save the user's current service property/storage analytics settings.
// This ensures that the sample does not permanently overwrite the user's analytics settings.
// Note however that logging and metrics settings will be modified for the duration of the sample.
userServiceProperties = await blobClient.GetServicePropertiesAsync();
// Get a reference to a sample container.
container = await CreateSampleContainerAsync(blobClient);
// Call Blob service client samples.
await CallBlobClientSamples(blobClient);
// Call blob container samples using the sample container just created.
await CallContainerSamples(container);
// Call blob samples using the same sample container.
await CallBlobSamples(container);
// Call shared access signature samples (both container and blob).
await CallSasSamples(container);
// CORS Rules
await CorsSample(blobClient);
// Page Blob Ranges
await PageRangesSample(container);
}
catch (StorageException e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
finally
{
// Delete the sample container created by this session.
if (container != null)
{
await container.DeleteIfExistsAsync();
}
// The sample code deletes any containers it created if it runs completely. However, if you need to delete containers
// created by previous sessions (for example, if you interrupted the running code before it completed),
// you can uncomment and run the following line to delete them.
//await DeleteContainersWithPrefix(blobClient, ContainerPrefix);
// Return the service properties/storage analytics settings to their original values.
await blobClient.SetServicePropertiesAsync(userServiceProperties);
}
}