I have a small Powershell script that uploads a file to blob storage. The idea is to run this as an inline script inside Devops once a build has been completed instead of having the path/file hardcoded like now.
If I run this in a Powershell command prompt on my computer, it works fine.
az storage blob upload --% --container-name mycontainer --account-name myaccount --name "File.zip" --file "c:\Projects\File.zip" --sas-token "{my token}"
However, I want to exchange the hardcoded path+file with a variable that my build pipleline can set. But here is where I haven't figured out how to actually use the variable.
The following does not work when I try to run it locally. To test I created a variable and then made a call.
// Create variable
New-Variable -Name "TestFile" -Value "c:\projects\File.zip"
(enter)
// Try to upload it
az storage blob upload --% --container-name mycontainer --account-name myaccount --name "File.zip" --file $TestFile --sas-token "{my token}"
Results in:
FileOperationError: [WinError 2] The system cannot find the file specified: '$TestFile'
I am assuming that I need to declare it in a different way or pipe it to make it work, but how?