Azure / arm-template-whatif

A repository to track issues related to what-if noise suppression
MIT License
91 stars 14 forks source link

XML APIM operation policies incorrectly compared #254

Open BlueYetii opened 2 years ago

BlueYetii commented 2 years ago

Describe the noise

Setting XML polices on APIM operations always show as being changed even when no changes have been made. Its looks like the comparison is not correctly matching the deployed policy with that in the template.

Resource type Microsoft.ApiManagement/service/apis/operations/policies

apiVersion 2021-08-01

Client (PowerShell, Azure CLI, or API) Azure CLI

Relevant ARM Template code bicep file

param apimName string
param apiName string

param opName string
param opDisplayName string
param opMethod string
param opUrlTemplate string
param opTemplateParams array = []

var basePolicyContent = trim(loadTextContent('../policies/api-policy-base.xml'))

resource api 'Microsoft.ApiManagement/service/apis@2021-08-01' existing = {
  name: '${apimName}/${apiName}'
}

resource operation 'Microsoft.ApiManagement/service/apis/operations@2021-08-01' = {
  name: opName
  parent: api
  properties: {
    displayName: opDisplayName
    method: opMethod
    urlTemplate: opUrlTemplate
    templateParameters: opTemplateParams
  }
}

resource policy 'Microsoft.ApiManagement/service/apis/operations/policies@2021-08-01' = {
  name: 'policy'
  parent: operation
  properties: {
    value: basePolicyContent
    format: 'xml'
  }
}

Expected response (i.e. "I expected no noise since the template has not been modified since the resources were deployed)

= Microsoft.ApiManagement/service/rcurran-api-test/apis/rcurran-api-v1-test/operations/get-blob-v1/policies/policy [2021-08-01]

Current (noisy) response (either include a screenshot of the what-if output, or copy/paste the text)

  ~ Microsoft.ApiManagement/service/rcurran-api-test/apis/rcurran-api-v1-test/operations/get-blob-v1/policies/policy [2021-08-01]
    ~ properties.value: "<policies>
        <inbound>
                <base />
        </inbound>
        <backend>
                <base />
        </backend>
        <outbound>
                <base />
        </outbound>
        <on-error>
                <base />
        </on-error>
</policies>" => "<policies>
        <inbound>
                <base />
        </inbound>
        <backend>
                <base />
        </backend>
        <outbound>
                <base />
        </outbound>
        <on-error>
                <base />
        </on-error>
</policies>"

Additional context Content of ../policies/api-policy-base.xml referenced in the template above.

<policies>
        <inbound>
                <base />
        </inbound>
        <backend>
                <base />
        </backend>
        <outbound>
                <base />
        </outbound>
        <on-error>
                <base />
        </on-error>
</policies>
alexanderameye commented 8 months ago

Any updates on this?