Hi, thank you for your question at Q&A. I hope you are doing well. I understand that you want to interact with a Flexible Postgres database with Azure CLI from an Azure DevOps Pipeline.
In your pipeline you can use the AzureCLI@2 task to use Azure CLI in your pipeline. Using the task you can then run the az postgres flexible-server connect
command to execute queries on the flexible server instance. More info on the command can be found here
The yaml for such a pipeline task may look like below:
- task: AzureCLI@2
name: queryPostgresDb
inputs:
azureSubscription: "myAzureResourceManagerServiceConnection"
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: >
az postgres flexible-server connect
--name my-flex-postgres-server
--database-name mydb
--querytext 'SELECT * FROM mytable;'