Setting access level of storage container programmatically (Ruby SDK)

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 17 hours 56 minutes ago
August 20th, 2015 9:28am

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

Free Windows Admin Tool Kit Click here and download it now
August 20th, 2015 10:59am

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

August 20th, 2015 11:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics