Sample Windows Azure Blob VB.NET Code

To easily upload byte arrays to Windows Azure blobs using VB.NET you will need to download the Windows Azure Tools for Visual Studio. After installing the SDK add a reference in your VB.NET project to the Microsoft.WindowsAzure.StorageClient.dll assembly. This will give us an easy way to upload a byte array to blob storage.

An example of writing to Windows Azure Blob storage you will need to add the following Import statements to your code: 

Imports Microsoft.WindowsAzure
Imports Microsoft.WindowsAzure.StorageClient 

To upload bytes to a blob write:

Dim storageAccount = New CloudStorageAccount(New Microsoft.WindowsAzure.StorageCredentialsAccountAndKey(_AccountName, _Key), New System.Uri(_BlobAddress, UriKind.Absolute), Nothing, Nothing)

Dim client = StorageAccount.CreateCloudBlobClient
Dim container = client.GetContainerReference(_ContainerAddress)
Dim blob = container.GetBlobReference(_Filename)

If blob IsNot Nothing Then
     blob.UploadByteArray(bytes)  
End

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s