Search code examples
postgresqlazurevnet

Adding VNET Rules to PostgreSQL Server via Azure ARM Template


I'm writing an Azure Resource Manager template automating the creation of a PostgreSQL database. I have successfully added a firewall rule with the following:

{
  "type": "firewallRules"
  "apiVersion": "2017-12-01",
  "dependsOn": [
    "[concat('Microsoft.DBforPostgreSQL/servers/', variables('serverName'))]"
    ],
    "location": "[parameters('location')]",
    "name": "[concat(variables('serverName'),'firewall')]",
    "properties": {
      "startIpAddress": "[parameters('firewallStartIpAddress')]",
      "endIpAddress": "[parameters('firewallEndIpAddress')]"
    }
}

However, what if I wanted to add a VNET rule instead? There doesn't appear to be any mention of this within the documentation here.

I have researched this and discovered this documentation but it is in regards to the 'Microsoft.Sql' resource, not the 'Microsoft.DBforPostgreSQL' resource.


Solution

  • Based on the API for PostgreSQL : Virtual Network Rules - Create Or Update , it seems MS missed it in the template.

    I have tried the template like the template for sql below, but it doesn't work.

    {
      "name": "string",
      "type": "Microsoft.DBforPostgreSQL/servers/virtualNetworkRules",
      "apiVersion": "2017-12-01",
      "properties": {
        "virtualNetworkSubnetId": "string",
        "ignoreMissingVnetServiceEndpoint": boolean
      }
    }
    

    Update:

    Per my test, after setting vnet rule of a SQL DB in the portal, I can find it via Azure Resource Explorer (you could access it in resource.azure.com), please refer to the screenshot.

    enter image description here

    enter image description here

    AFAIK, azure database for PostgreSQL supports API, azure CLI, azure portal to set vnet rule.

    But After setting it in the portal, I could not find it in the resource explorer and Automation script.

    enter image description here

    So I think postgresql does not support ARM template. If you want to improve the azure db for postgresql, you could post your idea in the feedback.

    Besides, I find an idea of ARM Template for MySQL, it is supported now. If you post it, I think it will be supported in the future.