Reputation: 79
I am creating a mysql server in Azure via Azure DevOps. I have run into an issue and would like to confirm if it is a bug or something I am doing wrong.
I have a bash script that creates the mysql server. That is ok.
In a subsequent step, when I create a database, I want to check if the server exists and if its sate is Ready
.
This is the script I am using
server_status=$(az mysql flexible-server show --resource-group $resourcegroup --name $sername --query "userVisibleState" --output tsv)
if [ -z "$server_status" ]; then
echo "Server [$sername] does not exist."
exit 1
elif [ "$server_status" != "Ready" ]; then
echo "Server [$sername] exists but is not in the 'Ready' state. Current state: $server_status."
exit 1
else
echo "Server [$sername] is in state: $server_status. Proceeding to create database [$dbname]."
server_status
is always null.
If I run this: server_id=$(az mysql flexible-server list --resource-group $resourcegroup --query "[?name=='$sername'].id" --output tsv)
I get the id accordingly. BUt I dont have the state. So it seesm like an issue with az mysql flexible-server show
.
Thanks in advance
Upvotes: 0
Views: 33
Reputation: 16178
The az mysql flexible-server show
does not return userVisibleState
. The body contains state
property:
az mysql flexible-server show --resource-group $resourcegroup --name $sername --query "state" --output tsv
Upvotes: 0