Azure Pipeline Releases sv Version causing authentication issues

Kevin Sunkwa-Mills 0 Reputation points
2024-03-20T19:55:30.5733333+00:00

I have a pipeline in my Releases in my Azure DevOps Repo. This pipeline is used to deploy our installers of our application into an Azure Storage account. It's been working great but recently has failed at one of the renaming steps where it runs into an "Unauthorized 401" error.

This step is a powershell script Put request that essentially is copying 1 file into another (replacing) and then deleting the other file. Both steps fail because of an unauthorized error.

I have not changed anything since the last deployment. But, the main difference I could find was that it was using a different "sv" when getting the SaS token from the storage account. The working versions had

sv=2021-10-04

and the now broken runs have

sv=2023-08-03

Does anyone know why this changes or how I can either:

  1. Hardcode the "sv" to the one that work or
  2. Alter my script to accommodate for the "sv" change?
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,462 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Azar 27,445 Reputation points MVP
    2024-03-20T20:14:59.36+00:00

    Hey there Kevin Sunkwa-Mills

    Thats a good question and thanks for using QandA platform.

    So if you know that the older version of the "sv" parameter (e.g., "sv=2021-10-04") works reliably and you don't anticipate needing the features of the newer version, you can manually specify the older version in your PowerShell script.

    and Alternatively, you can modify your PowerShell script to accommodate different "sv" versions dynamically. "sv" version based on the current date.

    
    $desiredSvVersion = "2021-10-04"  # Specify the desired "sv" version here
    
    $sasToken = New-AzStorageBlobSASToken -Container $containerName -Blob $blobName -Permission "rw" -Context $storageContext -ExpiryTime $expiryTime -FullUri -Service Blob -ResourceType Object -Protocol Https -StartTime $startTime -ErrorAction Stop -Version $desiredSvVersion
    
    # Example: Invoke-RestMethod -Uri $sasToken -Method Put -InFile $sourceFilePath -OutFile $destinationFilePath
    
    
    

    Kindly accept the answer if this helps thanks much.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.