Azure / arm-template-whatif

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

Microsoft.ApiManagement/service/policies #76

Open JanneMattila opened 4 years ago

JanneMattila commented 4 years ago

Describe the noise

Resource type (i.e. Microsoft.Storage/storageAccounts) Microsoft.ApiManagement/service/policies

apiVersion (i.e. 2019-04-01) 2019-01-01

Client (PowerShell, Azure CLI, or API) PowerShell

Relevant ARM Template code (we only need the resource object for the above resourceType and apiVersion, but if it's easier you can include the entire template link to relevant clip

      "resources": [
        {
          "name": "policy",
          "type": "policies",
          "apiVersion": "2019-01-01",
          "properties": {
            "value": "[concat(parameters('templateUrl'), 'policies/global.xml', parameters('templateToken'))]",
            "format": "rawxml-link"
          },
          "dependsOn": [
            "[parameters('apimName')]"
          ]
        }
      ]

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

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

  ~ Microsoft.ApiManagement/service/{serviceName}/policies/policy [2019-01-01]
    ~ properties.format: "xml" => "rawxml-link"
    ~ properties.value:  "<!--
    IMPORTANT:
    - Policy elements can appear only within the <inbound>, <outbound>, <backend> section elements.
    - Only the <forward-request> policy element can appear within the <backend> section element.
    - To apply a policy to the incoming request (before it is forwarded to the backend service), place a corresponding policy element within the <inbound> section element.
    - To apply a policy to the outgoing response (before it is sent back to the caller), place a corresponding policy element within the <outbound> section element.
    - To add a policy position the cursor at the desired insertion point and click on the round button associated with the policy.
    - To remove a policy, delete the corresponding policy statement from the policy document.
    - Policies are applied in the order of their appearance, from the top down.
-->
<policies>
        <inbound>
                <cors allow-credentials="false">
                        <allowed-origins>
                                <origin>*</origin>
                        </allowed-origins>
                        <allowed-methods preflight-result-max-age="300">
                                <method>*</method>
                        </allowed-methods>
                        <allowed-headers>
                                <header>*</header>
                        </allowed-headers>
                        <expose-headers>
                                <header>*</header>
                        </expose-headers>
                </cors>
        </inbound>
        <backend>
                <forward-request />
        </backend>
        <outbound />
        <on-error />
</policies>" => "https://{servicestorage}.blob.core.windows.net/local/policies/global.xml?sv=2019-02-02&sr=c&sig=...%2FonBKE%3D&se=2020-05-25T19%3A18%3A08Z&sp=r"

Additional context Problems seems to be clearly this:

    ~ properties.format: "xml" => "rawxml-link"

It does not understand difference of xml content and link to xml content.

This same problem happens with policies in different levels (e.g. API or API operation) if rawxml-link is used.

alex-frankel commented 4 years ago

Thanks for filing this. Technically, this is not a what-if noise issue. What-if is accurately telling you the difference between these two payloads. On PUT (creation), you submit a url, but on GET you are returned the actual content.

We'd like to work with the ApiManagement team to propose an alternative API design that would fix this. Will keep you updated on this thread.

alexanderameye commented 5 months ago

Any updates on this?