private static async Task SetAnonymousAccessLevelAsync(CloudBlobContainer container, BlobContainerPublicAccessType accessType)
{
try
{
// Read the existing permissions first so that we have all container permissions.
// This ensures that we do not inadvertently remove any shared access policies while setting the public access level.
BlobContainerPermissions permissions = await container.GetPermissionsAsync();
// Set the container's public access level.
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
await container.SetPermissionsAsync(permissions);
Console.WriteLine("Container public access set to {0}", accessType.ToString());
Console.WriteLine();
}
catch (StorageException e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
throw;
}
}