CloudBlobClient Constructor (String, StorageCredentials)

Storage Client Library NET API

[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 CloudBlobClient class using the specified Blob service endpoint and account credentials.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Usage

Visual Basic
Dim baseAddress As String
Dim credentials As StorageCredentials

Dim instance As New CloudBlobClient(baseAddress, credentials)

Syntax

Visual Basic
Public Sub New ( _
	baseAddress As String, _
	credentials As StorageCredentials _
)
C#
public CloudBlobClient (
	string baseAddress,
	StorageCredentials credentials
)
C++
public:
CloudBlobClient (
	String^ baseAddress, 
	StorageCredentials^ credentials
)
J#
JScript

Parameters

baseAddress

Type: System.String

The Blob service endpoint to use to create the client.

credentials

Type: Microsoft.WindowsAzure.StorageCredentials

The account credentials.

Example

The following code example creates a credentialed service client and uploads text content to a blob.

C# Copy Code
static void UploadBlobFromFile(string blobEndpoint, string accountName, string accountKey)
{
    //Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient =
        new CloudBlobClient(blobEndpoint, new StorageCredentialsAccountAndKey(accountName, accountKey));

    //Get a reference to a container, which may or may not exist.
    CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");
            
    //Create a new container, if it does not exist
    container.CreateIfNotExist();

    //Get a reference to a blob, which may or may not exist.
    CloudBlob blob = container.GetBlobReference("myfile.txt");

    //Upload content to the blob, which will create the blob if it does not already exist.
    blob.UploadFile("c:\\myfile.txt");
}

Platforms

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012

Change History

See Also