Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.68k stars 5.11k forks source link

[BUG] Resource ID for create backend in APIM not working as expected #29531

Open Thomaz-Peres opened 4 months ago

Thomaz-Peres commented 4 months ago

API Spec link

https://github.com/Azure/azure-rest-api-specs/blob/061505b89d5d0bbcc9f980e2276f79ff354ce286/specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-09-01-preview/definitions.json#L1957

API Spec version

2023-05-01-preview

Describe the bug

The error happens when I try to create the backend in APIM with the resource ID, and it doesn't find the resource.

I'm using terraform, but following the documentation, it looks like an Azure problem with the resource ID.

However, resource_id isn't found only with the resource_ID. You need to put https://management.azure.com/ before the resource_id.

Like this after formatting: https://management.azure.com/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1

Expected behavior

Create the APIM backend with only the resource ID, /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1.

Actual behavior

Not creating the APIM backend with only the resource ID

Reproduction Steps

As I said before, I'm using terraform.

To reproduce can use this example to test the error:

resource "azurerm_api_management_backend" "example" {
  name                = format("%s%s", "example", var.env)
  description         = format("%s%s", "example", var.env)
  api_management_name = var.apim_name
  resource_group_name = var.resource_group_name
  protocol            = "http"
  url                 = format("%s%s%s", "https://example", var.env, ".azurewebsites.net/api")
  resource_id         = var.example_id

  tls {
    validate_certificate_chain = false
    validate_certificate_name  = false
  }
}

And to reproduce without the error:

resource "azurerm_api_management_backend" "example" {
  name        = format("%s%s", "example", var.env)
  description = format("%s%s", "example", var.env)

  api_management_name = var.apim_name
  resource_group_name = var.resource_group_name

  protocol    = "http"
  url         = format("%s%s%s", "https://***", var.env, ".azurewebsites.net/api")
  resource_id = format("%s%s", "https://management.azure.com", var.example)

  tls {
    validate_certificate_chain = false
    validate_certificate_name  = false
  }
}

Environment

No response

v-jiaodi commented 4 months ago

@solankisamir Please help take a look, thanks.