Update to previous post – Capturing and Uploading Images to Azure Blob Storage from Universal Windows Apps
When you create a container from within the program code, it is by-default set to private. This is when you will not be able to access it directly. You need to set permissions explicitly on the container.
Setting permissions explicitly will fix this.
// HttpHandler class
private static readonly string StorageAccountName = Application.Current.Resources["StorageAccountName"].ToString();
private static readonly string StorageAccountKey = Application.Current.Resources["StorageAccountKey"].ToString();
private static readonly StorageCredentials cred = new StorageCredentials(StorageAccountName, StorageAccountKey);
public static readonly string storagePath = Application.Current.Resources["StoragePath"].ToString();
public static readonly CloudBlobContainer tempContainer = new CloudBlobContainer(new Uri(storagePath + "visitors"), cred);
Permission:
await HttpHandler.tempContainer.CreateIfNotExistsAsync();
BlobContainerPermissions permissions = new BlobContainerPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
await HttpHandler.tempContainer.SetPermissionsAsync(permissions);
blob = HttpHandler.tempContainer.GetBlockBlobReference(blobFileName);
await blob.DeleteIfExistsAsync();
await blob.UploadFromFileAsync(file);
Achindra Bhatnagar
20 projects • 161 followers
Windows Kernel Hacker, IoT Hobbyist, Enthusiast, Developer and Dreamer
Comments