From 7f900e80b879df42bad0266ccce26b1784cb2844 Mon Sep 17 00:00:00 2001 From: Steven <87738005+stemaMSFT@users.noreply.github.com> Date: Wed, 6 May 2026 15:25:41 -0700 Subject: [PATCH 1/3] Standardize AzAPI sample folder naming convention MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename folders to use provider suffix instead of prefix: - 101-azapi-lab-services → 101-lab-services-azapi - 101-azapi-eventhub-network-rules → 101-eventhub-network-rules-azapi This aligns with the convention used by dual-provider samples (e.g., 101-resource-group-azapi) where -azapi suffix indicates the AzAPI variant of an existing sample. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../TestRecord.md | 0 .../main-generic.tf | 0 .../main.tf | 0 .../providers.tf | 0 .../TestRecord.md | 0 .../{101-azapi-lab-services => 101-lab-services-azapi}/main.tf | 0 .../{101-azapi-lab-services => 101-lab-services-azapi}/outputs.tf | 0 .../providers.tf | 0 .../variables.tf | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename quickstart/{101-azapi-eventhub-network-rules => 101-eventhub-network-rules-azapi}/TestRecord.md (100%) rename quickstart/{101-azapi-eventhub-network-rules => 101-eventhub-network-rules-azapi}/main-generic.tf (100%) rename quickstart/{101-azapi-eventhub-network-rules => 101-eventhub-network-rules-azapi}/main.tf (100%) rename quickstart/{101-azapi-eventhub-network-rules => 101-eventhub-network-rules-azapi}/providers.tf (100%) rename quickstart/{101-azapi-lab-services => 101-lab-services-azapi}/TestRecord.md (100%) rename quickstart/{101-azapi-lab-services => 101-lab-services-azapi}/main.tf (100%) rename quickstart/{101-azapi-lab-services => 101-lab-services-azapi}/outputs.tf (100%) rename quickstart/{101-azapi-lab-services => 101-lab-services-azapi}/providers.tf (100%) rename quickstart/{101-azapi-lab-services => 101-lab-services-azapi}/variables.tf (100%) diff --git a/quickstart/101-azapi-eventhub-network-rules/TestRecord.md b/quickstart/101-eventhub-network-rules-azapi/TestRecord.md similarity index 100% rename from quickstart/101-azapi-eventhub-network-rules/TestRecord.md rename to quickstart/101-eventhub-network-rules-azapi/TestRecord.md diff --git a/quickstart/101-azapi-eventhub-network-rules/main-generic.tf b/quickstart/101-eventhub-network-rules-azapi/main-generic.tf similarity index 100% rename from quickstart/101-azapi-eventhub-network-rules/main-generic.tf rename to quickstart/101-eventhub-network-rules-azapi/main-generic.tf diff --git a/quickstart/101-azapi-eventhub-network-rules/main.tf b/quickstart/101-eventhub-network-rules-azapi/main.tf similarity index 100% rename from quickstart/101-azapi-eventhub-network-rules/main.tf rename to quickstart/101-eventhub-network-rules-azapi/main.tf diff --git a/quickstart/101-azapi-eventhub-network-rules/providers.tf b/quickstart/101-eventhub-network-rules-azapi/providers.tf similarity index 100% rename from quickstart/101-azapi-eventhub-network-rules/providers.tf rename to quickstart/101-eventhub-network-rules-azapi/providers.tf diff --git a/quickstart/101-azapi-lab-services/TestRecord.md b/quickstart/101-lab-services-azapi/TestRecord.md similarity index 100% rename from quickstart/101-azapi-lab-services/TestRecord.md rename to quickstart/101-lab-services-azapi/TestRecord.md diff --git a/quickstart/101-azapi-lab-services/main.tf b/quickstart/101-lab-services-azapi/main.tf similarity index 100% rename from quickstart/101-azapi-lab-services/main.tf rename to quickstart/101-lab-services-azapi/main.tf diff --git a/quickstart/101-azapi-lab-services/outputs.tf b/quickstart/101-lab-services-azapi/outputs.tf similarity index 100% rename from quickstart/101-azapi-lab-services/outputs.tf rename to quickstart/101-lab-services-azapi/outputs.tf diff --git a/quickstart/101-azapi-lab-services/providers.tf b/quickstart/101-lab-services-azapi/providers.tf similarity index 100% rename from quickstart/101-azapi-lab-services/providers.tf rename to quickstart/101-lab-services-azapi/providers.tf diff --git a/quickstart/101-azapi-lab-services/variables.tf b/quickstart/101-lab-services-azapi/variables.tf similarity index 100% rename from quickstart/101-azapi-lab-services/variables.tf rename to quickstart/101-lab-services-azapi/variables.tf From e31d9a02519c939f228da64caa45aa885ed356e9 Mon Sep 17 00:00:00 2001 From: Steven <87738005+stemaMSFT@users.noreply.github.com> Date: Wed, 6 May 2026 16:27:23 -0700 Subject: [PATCH 2/3] Fix CI: modernize eventhub-network-rules-azapi sample - Upgrade azapi provider from =0.1.0 to ~>2.0 - Upgrade azurerm provider from =3.0.2 to ~>3.0 - Replace jsonencode() body with native HCL (AzAPI v2.0+ pattern) - Randomize resource group name to avoid parallel CI conflicts - Remove stale .terraform.lock.hcl Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- quickstart/101-eventhub-network-rules-azapi/main-generic.tf | 6 +++--- quickstart/101-eventhub-network-rules-azapi/main.tf | 6 +++++- quickstart/101-eventhub-network-rules-azapi/providers.tf | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/quickstart/101-eventhub-network-rules-azapi/main-generic.tf b/quickstart/101-eventhub-network-rules-azapi/main-generic.tf index a8abfec49..7eb4baca3 100644 --- a/quickstart/101-eventhub-network-rules-azapi/main-generic.tf +++ b/quickstart/101-eventhub-network-rules-azapi/main-generic.tf @@ -4,7 +4,7 @@ resource "azapi_update_resource" "qs101" { name = "default" parent_id = azurerm_eventhub_namespace.qs101.id - body = jsonencode({ + body = { properties = { defaultAction = "Deny" publicNetworkAccess = "Enabled" @@ -12,7 +12,7 @@ resource "azapi_update_resource" "qs101" { { ignoreMissingVnetServiceEndpoint = false subnet = { - # API bug, returned id replaced `resourceGroups` with `resourcegroups` + # API bug: returned id replaces `resourceGroups` with `resourcegroups` id = replace(azurerm_subnet.qs101.id, "resourceGroups", "resourcegroups") } } @@ -24,5 +24,5 @@ resource "azapi_update_resource" "qs101" { } ] } - }) + } } diff --git a/quickstart/101-eventhub-network-rules-azapi/main.tf b/quickstart/101-eventhub-network-rules-azapi/main.tf index 7c89bfddd..e05f36c67 100644 --- a/quickstart/101-eventhub-network-rules-azapi/main.tf +++ b/quickstart/101-eventhub-network-rules-azapi/main.tf @@ -1,5 +1,9 @@ +resource "random_pet" "rg_name" { + prefix = "rg-qs101-eh-rules" +} + resource "azurerm_resource_group" "qs101" { - name = "rg-qs101-eh-rules" + name = random_pet.rg_name.id location = "westus2" } diff --git a/quickstart/101-eventhub-network-rules-azapi/providers.tf b/quickstart/101-eventhub-network-rules-azapi/providers.tf index 90d294348..58dca6da1 100644 --- a/quickstart/101-eventhub-network-rules-azapi/providers.tf +++ b/quickstart/101-eventhub-network-rules-azapi/providers.tf @@ -2,17 +2,17 @@ terraform { required_providers { azapi = { source = "azure/azapi" - version = "=0.1.0" + version = "~>2.0" } azurerm = { source = "hashicorp/azurerm" - version = "=3.0.2" + version = "~>3.0" } random = { source = "hashicorp/random" - version = "=3.1.2" + version = "~>3.0" } } } From 898f1e03e684ae0da2a6a70476f04f070e8d7f08 Mon Sep 17 00:00:00 2001 From: Steven <87738005+stemaMSFT@users.noreply.github.com> Date: Wed, 6 May 2026 16:52:31 -0700 Subject: [PATCH 3/3] Fix idempotent check: ignore body changes on update resource The Terratest CI runs an idempotent plan after apply. azapi_update_resource sends a PATCH and the API response includes additional normalized properties not in the original request, causing plan drift. lifecycle ignore_changes on body is the standard pattern for update resources. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- quickstart/101-eventhub-network-rules-azapi/main-generic.tf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/quickstart/101-eventhub-network-rules-azapi/main-generic.tf b/quickstart/101-eventhub-network-rules-azapi/main-generic.tf index 7eb4baca3..a6b5b5dce 100644 --- a/quickstart/101-eventhub-network-rules-azapi/main-generic.tf +++ b/quickstart/101-eventhub-network-rules-azapi/main-generic.tf @@ -25,4 +25,10 @@ resource "azapi_update_resource" "qs101" { ] } } + + # The API response includes additional normalized properties not in the request, + # which causes plan drift on the idempotent check. Safe to ignore for update resources. + lifecycle { + ignore_changes = [body] + } }