[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See
Storage Client Library for the latest version.]
Initializes a new instance of the
CloudBlob class using an absolute URI to the blob and a set of credentials.
Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)
Usage
Visual Basic |
---|
Dim blobAbsoluteUri As String
Dim credentials As StorageCredentials
Dim instance As New CloudBlob(blobAbsoluteUri, credentials) |
Syntax
Visual Basic |
---|
Public Sub New ( _
blobAbsoluteUri As String, _
credentials As StorageCredentials _
) |
C# |
---|
public CloudBlob (
string blobAbsoluteUri,
StorageCredentials credentials
) |
C++ |
---|
public:
CloudBlob (
String^ blobAbsoluteUri,
StorageCredentials^ credentials
) |
Parameters
- blobAbsoluteUri
Type: System.String
The absolute URI to the blob.
- credentials
Type: Microsoft.WindowsAzure.StorageCredentials
The account credentials.
Example
The following code example creates a new blob using an absolute URI and storage credentials.
C# | Copy Code |
---|
static void WriteToBlobViaSAS1(Uri blobEndpoint, string accountName, string accountKey)
{
// Create service client for credentialed access to the Blob service.
CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));
CloudBlob blob = blobClient.GetBlobReference("mycontainer/myblob.txt");
// Upload text to the blob, which will create it if it does not already exist.
blob.UploadText("a text blob");
// Create a shared access signature to use for delegated access to the blob.
// Specify an access policy that indicates the start time, expiry time, and permissions granted for the signature.
string signature = blob.GetSharedAccessSignature(new SharedAccessPolicy()
{
// If valid immediately, don’t set SharedAccessStartTime. To avoid clock skew, use a duration of less than one hour.
// SharedAccessStartTime = DateTime.Now,
// Specify the expiration time for the signature.
SharedAccessExpiryTime = DateTime.Now.AddMinutes(55),
// Specify the permissions granted by the signature.
Permissions = SharedAccessPermissions.Write | SharedAccessPermissions.Read
});
// Get a reference to the blob using the shared access signature.
CloudBlob blobSAS = new CloudBlob("http://storagesample.blob.core.windows.net/mycontainer/myblob.txt", new StorageCredentialsSharedAccessSignature(signature));
// Update the contents of the blob, then read them.
blobSAS.UploadText("a text blob updated using a shared access signature");
Console.WriteLine(blobSAS.DownloadText());
}
|
Platforms
Change History
See Also