6

How can i get url of the blob i just uploaded using powershell.My code currently is

$storagekey=Get-AzureStorageKey -StorageAccountName appstorageacc
$ctx=New-AzureStorageContext -StorageAccountName 
appstorageacc -   StorageAccountKey $storagekey.Primary
Set-AzureStorageBlobContent -File C:\Package\StarterSite.zip 
-Container   clouddata -Context $ctx -Force

Blob is uploaded successfully, but how can i get it's url out?

2 Answers 2

9

Retrieve blob information using the Get-AzureStorageBlob cmdlet and select the AbsoluteUri:

(Get-AzureStorageBlob -blob 'StarterSite.zip' -Container 'clouddata ').ICloudBlob.uri.AbsoluteUri
2
4

Another option: just capture the result of Set-AzureStorageBlobContent

$result = Set-AzureStorageBlobContent -File C:\Package\StarterSite.zip
$blobUri = $result.ICloudBlob.Uri.AbsoluteUri

It's not necessary to call Get-AzureStorageBlob after calling Set-AzureStorageBlobContent.

Set-AzureStorageBlobContent returns the same object type that Get-AzureStorageBlob returns.

More details

The output type is AzureStorageBlob for both Get-AzureStorageBlob and Set-AzureStorageBlobContent

AzureStorageBlob has a ICloudBlob property

AzureStorageBlob.ICloudBlob getter returns a CloudBlob which has the Uri property

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.