Reputation: 69
Trying to run the following command in a Powershell script:
$statblob = az storage blob exists --container-name "dev-tfstate" --name "mh/fw-mh-$varenv-__region__-__suffix__.tfstate" --account-key $blobkey --account-name "fwdevstate767442" --subscription $mgtsub | ConvertFrom-Json
And I get the following error:
ERROR: the following arguments are required: --container-name/-c, --name/-n
I was getting the same error with the --account-name
argument until I removed the variable and hard coded the name into the script instead. The values are valid, it just doesn't seem to recognize that the arguments are there?
Edit: I changed the arguments to their aliases of -c and -n, and now I get the error on the account-name argument.
ERROR: unrecognized arguments: account-name fwdevstate767442
Upvotes: 1
Views: 7556
Reputation: 69
Finally found a fix. Had to do with variables not being interpreted right for some reason. Setting them as environment variables within the function solved it and the script ran fine afterward.
Upvotes: 2
Reputation: 3398
We tried this command without any errors, the problem might be that you run this Azure CLI command inside your Powershell script.
There are two solutions:
A solution is to wrap the call to Get-AzureStorageBlob in a try/catch and catch ResourceNotFoundException to determine that the blob doesn't exist.
Upvotes: 1