none
Setting access level of storage container programmatically (Ruby SDK)

    Question

  • I'm having an issue where I'm creating a container programmatically using the Ruby SDK, and it is being set to Private immediately.

    I'm using the Azure Ruby SDK found here: https://github.com/Azure/azure-sdk-for-ruby

    def create_container(container_name)
      container = Azure.blobs.create_container(container_name)
    end

    How do I set the access level to Public Blob? Right now I have to go to the portal and set it manually.


    • Edited by Josh SBA Thursday, August 20, 2015 1:25 PM
    Thursday, August 20, 2015 1:24 PM

Answers

  • If you want to make the files in the container public, you can set the container's permissions.

    You can just modify the create_container() call to pass the :public_access_level option:

    container = azure_blob_service.create_container("test-container", 
      :public_access_level => "<public access level>")

    Valid values for the :public_access_level option are:

    • blob: Specifies full public read access for container and blob data. Clients can enumerate blobs within the container via anonymous request, but cannot enumerate containers within the storage account.

    • container: Specifies public read access for blobs. Blob data within this container can be read via anonymous request, but container data is not available. Clients cannot enumerate blobs within the container via anonymous request.

    Alternatively, you can modify the public access level of a container by using set_container_acl() method to specify the public access level.

    The following example changes the public access level to container:

    azure_blob_service.set_container_acl('test-container', "container")

    For more details: How to use Blob storage from Ruby


    Please mark as answer or vote as helpful if my reply does

    • Marked as answer by Josh SBA Friday, August 21, 2015 12:20 PM
    Thursday, August 20, 2015 2:55 PM

All replies

  • If you want to make the files in the container public, you can set the container's permissions.

    You can just modify the create_container() call to pass the :public_access_level option:

    container = azure_blob_service.create_container("test-container", 
      :public_access_level => "<public access level>")

    Valid values for the :public_access_level option are:

    • blob: Specifies full public read access for container and blob data. Clients can enumerate blobs within the container via anonymous request, but cannot enumerate containers within the storage account.

    • container: Specifies public read access for blobs. Blob data within this container can be read via anonymous request, but container data is not available. Clients cannot enumerate blobs within the container via anonymous request.

    Alternatively, you can modify the public access level of a container by using set_container_acl() method to specify the public access level.

    The following example changes the public access level to container:

    azure_blob_service.set_container_acl('test-container', "container")

    For more details: How to use Blob storage from Ruby


    Please mark as answer or vote as helpful if my reply does

    • Marked as answer by Josh SBA Friday, August 21, 2015 12:20 PM
    Thursday, August 20, 2015 2:55 PM
  • Hi,If you create a storage account in Windows Azure subscription, you can have 3 options to create containers. There are many ways by which you can create container.

    They are – Private, Public Blob and Public Container.

    You can refer https://azure.microsoft.com/en-in/documentation/articles/storage-ruby-how-to-use-blob-storage/ 

    It will provide you detailed explanation along with github link

    https://github.com/Blackmist/azure-content-training/blob/master/articles/storage-ruby-how-to-use-blob-storage.md

    Thanks

    Abhishek

    Thursday, August 20, 2015 3:16 PM
  • The second one worked for me. Thanks!
    Friday, August 21, 2015 12:20 PM