You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article shows how to use the storage account key to create a service SAS for a blob with the Blob Storage client library for Java.
22
+
This article shows how to use the storage account key to create a service SAS for a container or blob with the Blob Storage client library for Java.
23
23
24
24
## About the service SAS
25
25
26
26
A service SAS is signed with the account access key. You can use the [StorageSharedKeyCredential](/java/api/com.azure.storage.common.storagesharedkeycredential) class to create the credential that is used to sign the service SAS.
27
27
28
28
You can also use a stored access policy to define the permissions and duration of the SAS. If the name of an existing stored access policy is provided, that policy is associated with the SAS. To learn more about stored access policies, see [Define a stored access policy](/rest/api/storageservices/define-stored-access-policy). If no stored access policy is provided, the code examples in this article show how to define permissions and duration for the SAS.
29
29
30
-
## Create a service SAS for a blob
30
+
## Create a service SAS
31
+
32
+
You can create a service SAS for a container or blob, based on the needs of your app.
33
+
34
+
### [Container](#tab/container)
35
+
36
+
You can create a service SAS to delegate limited access to a container resource using the following method:
SAS signature values, such as expiry time and signed permissions, are passed to the method as part of a [BlobServiceSasSignatureValues](/java/api/com.azure.storage.blob.sas.blobservicesassignaturevalues) instance. Permissions are specified as a [BlobContainerSasPermission](/java/api/com.azure.storage.blob.sas.blobcontainersaspermission) instance.
41
+
42
+
The following code example shows how to create a service SAS with read permissions for a container resource:
You can use a service SAS to authorize a client object to perform operations on a container or blob based on the permissions granted by the SAS.
63
+
64
+
### [Container](#tab/container)
65
+
66
+
The following code examples show how to use the service SAS to authorize a [BlobContainerClient](/java/api/com.azure.storage.blob.blobcontainerclient) object. This client object can be used to perform operations on the container resource based on the permissions granted by the SAS.
67
+
68
+
First, create a [BlobServiceClient](/java/api/com.azure.storage.blob.blobserviceclient) object signed with the account access key:
Then, generate the service SAS as shown in the earlier example and use the SAS to authorize a [BlobContainerClient](/java/api/com.azure.storage.blob.blobcontainerclient) object:
The following code example shows how to use the service SAS created in the earlier example to authorize a [BlobClient](/java/api/com.azure.storage.blob.blobclient) object. This client object can be used to perform operations on the blob resource based on the permissions granted by the SAS.
45
88
46
89
First, create a [BlobServiceClient](/java/api/com.azure.storage.blob.blobserviceclient) object signed with the account access key:
@@ -60,10 +103,16 @@ Then, generate the service SAS as shown in the earlier example and use the SAS t
To learn more about using the Azure Blob Storage client library for Java, see the following resources.
66
111
112
+
### Code samples
113
+
114
+
-[View code samples from this article (GitHub)](https://github.com/Azure-Samples/AzureStorageSnippets/blob/master/blobs/howto/Java/blob-devguide/blob-devguide-blobs/src/main/java/com/blobs/devguide/blobs/BlobSAS.java)
0 commit comments