Search code examples
azurepowershellazure-blob-storageblobazure-storage

How to make blob specific version as current version using PowerShell or cli


I have versioning enabled on storage account. I would like to make specific blob version as a current version using powershell or cli. Please find the attached screenshot herewith.Thanks.

enter image description here

Required a powershell or cli script.


Solution

  • The PowerShell Cmdlet you would want to use is Copy-AzStorageBlob. The source blob URL you would be using would be the one of the blob version (something like https://account.blob.core.windows.net/container/blob?versionid=<blob-version>) Your code would be something like:

    $sourceBlobUri = "Blob URL with version"
    Copy-AzStorageBlob -AbsoluteUri $sourceBlobUri -DestContainer "container" -DestBlob "blob"