Get Microsoft.WindowsAzure.Storage.dll using NuGet
- Navigate to this by first going to the Windows Azure Downloads site.
- Select .NET.
- Select Client libraries under Resources.
- Instructions on how to download Windows Azure Storage are found here.
Here is the code I'm using to download files from blob storage
Param (
[Parameter(Mandatory=$true)] [String] $StorageAccountName,
[Parameter(Mandatory=$true)] [String] $AccessKey,
[Parameter(Mandatory=$true)] [String] $BlobFilename,
[Parameter(Mandatory=$true)] [String] $LocalFilename,
[String] $StorageAccountEndpoint = "http://$storageAccountName.blob.core.windows.net/"
)
Add-Type -Path '.\Microsoft.WindowsAzure.Storage.dll'
$BlobFilename = $BlobFilename.Replace('%20', ' ').Trim('/')
$storageCredentials = New-Object Microsoft.WindowsAzure.Storage.Auth.StorageCredentials($StorageAccountName, $AccessKey)
$blobClient = New-Object Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient($StorageAccountEndpoint, $storageCredentials)
$blob = $blobClient.GetBlobReferenceFromServer($BlobFilename)
$stream = New-Object System.IO.FileStream($LocalFilename, [System.IO.FileMode]::Create)
$blob.DownloadToStream($stream)
$stream.Close()
References:
Microsoft.WindowsAzure.Storage.Blob Namespace
CloudBlobClient class
Microsoft.WindowsAzure.Storage.Auth Namespace
StorageCredentials class
Microsoft.WindowsAzure.Storage.Blob Namespace
CloudBlobClient class
Microsoft.WindowsAzure.Storage.Auth Namespace
StorageCredentials class
No comments:
Post a Comment