Deploying PostgreSQL Flexible Server with azure.extensions parameter in ARM template fails with InternalServerError

Kyle L 21 Reputation points
2022-11-07T17:50:23.9+00:00

I'm trying to set up a PostgreSQL Flexible Server through an ARM template. I'm setting azure.extensions in the template.

The first time I deploy the template, sometimes works fine, other times it fails.
When I deploy the template again (to update the existing server), the deployment always fails with an InternalServerError.

Here's a snippet of the template:

   resource postgresAllowedExtensions 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2021-06-01' = {  
     parent: postgres  
     name: 'azure.extensions'  
     properties: {  
       value: 'pgcrypto,postgis,timescaledb,uuid-ossp'  
       source: 'user-override'  
     }  
   }  
     
   resource postgresPreloadLibraries 'Microsoft.DBforPostgreSQL/flexibleServers/configurations@2021-06-01' = {  
     parent: postgres  
     dependsOn: [postgresAllowedExtensions]  
     name: 'shared_preload_libraries'  
     properties: {  
       value: 'timescaledb'  
       source: 'user-override'  
     }  
   }  

And an example error:

Resource: <resource name>/azure.extensions

Status message:

   {  
       "status": "Failed",  
       "error": {  
           "code": "InternalServerError",  
           "message": "An unexpected error occured while processing the request. Tracking ID: '4fe99e89-d3e4-4597-b0ea-6ba1d9acb138'"  
       }  
   }  

Setting the parameters through the Azure CLI works fine, for example:

   az postgres flexible-server parameter set \  
     --resource-group "$groupName" \  
     --server-name "$pgFlexServerName" \  
     --name "azure.extensions" \  
     --value "pgcrypto,postgis,timescaledb,uuid-ossp"  

Changing the parameter through the Azure Portal also works fine. It's only through the ARM template that I'm getting this error.

Azure Database for PostgreSQL
{count} votes

Accepted answer
  1. GeethaThatipatri-MSFT 27,717 Reputation points Microsoft Employee
    2022-11-08T13:01:25.637+00:00

    @Kyle L The error is because you are not setting up the order in the ARM template. can you please use "dependsOn" in your template as mentioned here to make sure the extension is created after the last firewall rules created. Also, in the template, multiple firewall rules should use this 'dependsOn' to make sure the requests are coming in sequence Otherwise, those may randomly timeout and failed the deployment.

    258316-image.png

    I hope this information helps, let me know if you are still facing any issues.

    Regards
    Geetha


0 additional answers

Sort by: Most helpful