locked
Is it possible to set permissions on CloudBlockBlob? RRS feed

  • Question

  • Hello,

    I would like to know if i can set permissions on CloudBlockBlob? from following given example, which I am deleting [soureBlockBlob]. The whole idea is to restrict it from Public access for any use. I won't like to delete, just restrict access ... is it possible, if yes, how? I need a running sample code plz.

                var blobs = storageAccount.CreateCloudBlobClient().ListBlobsWithPrefix(blobContainerName + "/" + sourceFolderName, requestOptions);
    
                foreach (var blob in blobs)
                {
                    var sourceBlockBlob = blob as CloudBlockBlob;
    
                    sourceBlockBlob.DeleteIfExists();
                    Console.WriteLine(string.Format("Successfully deleted {0}", sourceBlockBlob.Name));
                }


    Shamshad Ali


    Shamshad Ali

    Monday, May 27, 2013 6:43 AM

Answers

  • Hi,

    Try this:

        // Create a permission policy to set the public access setting for the container.
        BlobContainerPermissions containerPermissions = new BlobContainerPermissions();

        // The public access setting explicitly specifies that the container is private,
        // so that it can't be accessed anonymously.
        containerPermissions.PublicAccess = BlobContainerPublicAccessType.Off;

        //Set the permission policy on the container.
        container.SetPermissions(containerPermissions);

    http://msdn.microsoft.com/en-us/library/windowsazure/ee758387.aspx

    Thanks,


    QinDian Tang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, May 27, 2013 7:25 AM