Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As mentioned by the previous answers, the best practice is usually to control the access to your blob container using shared access signatures (SAS) or a stored access policy. These can be used to create an access token (string) you can pass to your client without revealing your account key.</p> <p>However, it is also possible to specify the level of public read access to the blobs and metadata saved in the container. Public access is the level of read permission automatically given an anonymous user that is in possession the public access url for the container or blob. You cannot use public access to give anonymous users write permissions to the container. If you need to give write permission to users that are not in possession of the account key of your Azure storage account, then you will need to provide those users with a token in the form of a url the references a shared access signature or a shared access policy. If the public access to the blob container is not currently off (private,) anonymous user will be able to read all blobs in the container using a public access url such as the following.</p> <pre><code>http://grassy.blob.core.windows.net/container1/image2.jpg </code></pre> <p>When you create the container, you can set the value of the publicAccess property to the appropriate constant of the BlobContainerPublicAccessType enum. The value of the publicAccess property can be one of the following three constants which specify the level of public read access. </p> <p>• BLOB – The public can read the content and metadata of blobs within this container, but cannot read container metadata or list the blobs within the container.</p> <p>• CONTAINER – The public can read blob content and metadata and container metadata, and can list the blobs within the container.</p> <p>• OFF – Specifies no public access. Only the account owner can read resources in this container. </p> <p>So in this case the public access level might be set to CONTAINER. For example:</p> <pre><code>public static void main(String[] args) throws InvalidKeyException, URISyntaxException, StorageException { Account creds = new Account(); final String storageConnectionString = creds.getstorageconnectionstring(); CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString); CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference("container1"); container.createIfNotExist(); BlobContainerPermissions containerPermissions = new BlobContainerPermissions(); containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER); container.uploadPermissions(containerPermissions); BlobContainerPublicAccessType access1 = containerPermissions.getPublicAccess(); System.out.println("Public access to " + container.getName() + " is set to: " + access1); } </code></pre> <p>If the public access level on container1 has been set to CONTAINER, an anonymous user should be able to list the blobs in container1 knowing only the storage account AccountName ("grassy") and the container name, but without needing to know the AccountKey. For example, an anonymous application might use java code similar to the following:</p> <pre><code>public static void main(String[] args) throws InvalidKeyException, URISyntaxException, StorageException, FileNotFoundException, IOException { URI baseuri = new URI("http://grassy.blob.core.windows.net"); CloudBlobClient blobclient = new CloudBlobClient(baseuri); CloudBlobContainer container = blobclient.getContainerReference("container1"); for (ListBlobItem blobItem : container.listBlobs()){System.out.println(blobItem.getUri());} } </code></pre> <p>However, as discussed, it is a better practice to avoid giving anonymous users access. Instead control access to the container using a SAS or policy and pass on the token to only known users. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload