0

In order to save money, I'm using az synapse sql pool pause and az synapse sql pool resume, so that the Synapse dedicated pool database only turns on to run tests when there is a Pull Request, then shuts down after.

The challenge is that:

  • az synapse sql pool resume fails is the database is already resumed, and
  • az synapse sql pool pause fails if the database is already paused

below is an example output of what happens when one of the above situation occurs

Command group 'synapse' is in preview and under development.
Reference and support levels: https://aka.ms/CLI_refstatus

Deployment failed.
Correlation ID: 062ea436-f0f0-4c11-a3e4-4df92cdaf6b5.
An unexpected error occured while processing the request.
Tracking ID: 'ba5ce906-5631-42ad-b3f4-a659095bdbe3'

Exited with code exit status 1

How can I make this command tolerate the state already being achieved?

Anders Swanson
  • 3,637
  • 1
  • 18
  • 43

1 Answers1

1

here's how you would resume the database if and only if it were currently paused, then wait for it to be resumed/"Online". requires 3 separate commands...

state=$(az synapse sql pool show \  
    --name $DB_NAME \
    --resource-group $RG_NAME \
    --workspace-name $WKSPC_NAME \
    --query "status")

if [ "$state" = "Paused" ]; then
  echo "Resuming pool!"
  az synapse sql pool resume
    --name $DB_NAME
    --resource-group $RG_NAME
    --workspace-name $WKSPC_NAME

  az synapse sql pool wait
    --sql-pool-name $DB_NAME
    --resource-group $RG_NAME
    --workspace-name $WKSPC_NAME
    --custom "state==Online" 

fi
Anders Swanson
  • 3,637
  • 1
  • 18
  • 43