azureazure-postgresql

Azure PostgresSQL : Error: Code="FeatureSwitchNotEnabled" while trying to add VNET Rules


I am getting the following error while trying to add VNET Rules for Azure PostgresSQL database

│ Virtual Network Rule Name: "allow-app-service-access-0"): performing CreateOrUpdate: virtualnetworkrules.VirtualNetworkRulesClient#CreateOrUpdate: Failure sending request: StatusCode=0 -- Original Error: Code="FeatureSwitchNotEnabled" Message="Requested feature is not enabled"

resource "azurerm_postgresql_virtual_network_rule" "allow_app_service_access" {
  count = length(var.subnet_whitelist)

  name                                 = "allow-app-service-access-${count.index}"
  resource_group_name                  = var.resource_group_name
  server_name                          = azurerm_postgresql_server.app_postgres_server.name
  subnet_id                            = var.subnet_whitelist[count.index]
  ignore_missing_vnet_service_endpoint = true
}

enter image description here

I tried enabling the feature

az feature register --namespace Microsoft.DBforPostgreSQL  --name "firewallRuleAllowAzureServices"

az feature register --namespace Microsoft.DBforPostgreSQL  --name "vnet"

and the status is

  {
    "id": "/subscriptions/id/providers/Microsoft.Features/providers/Microsoft.DBforPostgreSQL/features/firewallRuleAllowAzureServices",
    "name": "Microsoft.DBforPostgreSQL/firewallRuleAllowAzureServices",
    "properties": {
      "state": "Pending"
    },
    "type": "Microsoft.Features/providers/features"
  },
  {
    "id": "/subscriptions/id/providers/Microsoft.Features/providers/Microsoft.DBforPostgreSQL/features/vnet",
    "name": "Microsoft.DBforPostgreSQL/vnet",
    "properties": {
      "state": "Pending"
    },
    "type": "Microsoft.Features/providers/features"
  } 

Solution

  • I had to save "Deny public network access" before I can make any changes into the VNET rules

    enter image description here