I'm not sure if I understand OP's question correctly, and it's been 9 months since OP posted the question. But this appears to be the right answer.
At least one Microsoft-hosted agent on Azure Devops has PostgreSQL built in, just not enabled by default. Enabling and using it is simple.
The "Microsoft-hosted agents" page, https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/hosted?view=azure-devops&tabs=yaml, has a table listing the available agents. You can click on the link in the rightmost column to see a list of included software. The link for the agent vs2017-win2016 points to a list of all the software pre-installed on the Microsoft Windows Server 2016 Datacenter. Scrolling down the page, or searching for "postgres", reveals the pertinent information for PostgreSQL.
This example Azure Pipelines job can be used to start PostgreSQL.
- job: foo-postgresql-bar
pool:
vmImage: 'vs2017-win2016'
steps:
- powershell: |
echo 'PGBIN is ' $env:PGBIN
echo 'PGDATA is ' $env:PGDATA
echo 'PGROOT is ' $env:PGROOT
echo 'Contents of PGBIN'
ls $env:PGBIN
Set-Service postgresql-x64-13 -StartupType manual
Start-Service postgresql-x64-13
Get-CimInstance win32_service | Where-Object Name -eq "postgresql-x64-13"
displayName: 'Setup PostgreSQL'
Only the Set-Service
and Start-Service
commands are required; the rest of the PowerShell script is optional.
The echo
and ls
commands simply verify the information from the table. The Set-Service
command enables the service, the Start-Service
command starts the service, and the Get-CimInstance
command verifies that it's running.
In a production environment, you may read the return code after Start-Service
, instead of using the Get-CimInstance
command, in order to verify that the service is running.