Azure / terraform-provider-azapi

Terraform provider for Azure Resource Manager Rest API
https://registry.terraform.io/providers/Azure/azapi/latest
Mozilla Public License 2.0
181 stars 48 forks source link

AzAPI Microsoft.Relay namespaces #558

Open v-vsj opened 2 months ago

v-vsj commented 2 months ago

AzAPI resource/AzAPI_update_resource/AzAPI_resource_action : None of the resources able to disable the public network access property for the Relay Namespace type = "Microsoft.Relay/namespaces@2021-11-01"

ms-henglu commented 2 months ago

Hi @v-vsj ,

Thank you for taking time to report this issue!

@hqhqhqhqhqhqhqhqhqhqhq, please help check this issue and provide an example.

hqhqhqhqhqhqhqhqhqhqhq commented 2 months ago

@v-vsj Hi, I believe this is a Relay RP's issue, even we pass "Disabled" to it, it still uses "Enabled" for publicNetworkAccess.

This is a similar issue to: https://github.com/Azure/bicep-types-az/issues/2038

We will contact the service team for more support about this. In the mean time, as a work around, you can use this script to deploy the resource with publicNetworkAccess set to Disabled.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
  }
}

provider "azapi" {
}

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "example" {
  name     = "test-rg"
  location = "West US"
}

resource "azapi_resource" "example" {
  type      = "Microsoft.Relay/namespaces@2021-11-01"
  parent_id = azurerm_resource_group.example.id
  name      = "test-ns"
  location  = "westus"
  body = {
    properties = {
    }
    sku = {
      name = "Standard"
      tier = "Standard"
    }
  }

  schema_validation_enabled = true
  response_export_values    = ["*"]
}

resource "azapi_update_resource" "example" {
  type        = "Microsoft.Relay/namespaces/networkRuleSets@2021-11-01"
  resource_id = "${azapi_resource.example.id}/networkRuleSets/default"
  body = {
    properties = {
      publicNetworkAccess = "Disabled"
    }
  }
  depends_on = [azapi_resource.example]
}

it created the resource fine, and also tried destroying also had no problems. In the Azure Portal, it shows up that it is created with publicNetworkAccess set to Disabled.

image

Let me know if this solves the problem. cc @ms-henglu

v-vsj commented 2 months ago

Thanks for the workaround. Will deploy and revert you the outcome