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
Sign up to request clarification or add additional context in comments.

2 Comments

How did you find this? Looking at the object/properties returned from Get-AzureStorageBlob, I had no indication there was more info available.
@Orangutech At the bottom in the documentation (learn.microsoft.com/en-us/powershell/module/azure.storage/…) you see the output of the cmdlet
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.