Do you have any idea why it’s not working correctly?
$resut = az sql db show --name "NotExistingDB" --resource-group "rg" --server "server" | ConvertFrom-Json
checking if database exists – it should return false
because it does not.
$?
:- Writing result of last command, it returns $true
in my case but should return $false
.
2
Answers
https://github.com/Azure/azure-cli/pull/24015
This change caused a number of issues and is being reverted. Though your specific issue is not listed, I can also reproduce it and it fits with the change. A fix will be released soon as far as I can see.
You can also try going back to an old version of Azure CLI to see if that fixes the issue.
I have reproduced in my environment by using your command, and I got the expected results as below:
I got true when the resource is found else, I got false as discussed in comments too.
I used the newer version of powershell and cli , please try to use it: