azureazure-resource-managerazure-bicepazure-postgresql

Is there a way to set "Allow access to Azure services" in Microsoft.DBforPostgreSQL/servers using Bicep?


I've been working with Microsoft.DBforPostgreSQL/servers resource and Azure Bicep specifically using this reference. I am missing parameter to set my database accessable from Azure resouces (see the picture attached).

enter image description here

I thought publicNetworkAccess: 'Enabled' should do the trick, but it's not. Any thoughts / recommendations?

Thanks.


Solution

  • The Allow access to Azure services setting can be scripted using a firewall rule for IP 0.0.0.0:

    param serverName string
    
    resource server 'Microsoft.DBforPostgreSQL/servers@2017-12-01' existing = {
      name: serverName
    }
    
    resource allowAllWindowsAzureIps 'Microsoft.DBforPostgreSQL/servers/firewallRules@2017-12-01' = {
      name: 'AllowAllWindowsAzureIps' // don't change the name
      parent: server
      properties: {
        endIpAddress: '0.0.0.0'
        startIpAddress: '0.0.0.0'
      }
    }