Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PolicyFragment ARM Template deployment fails - The policy fragment is not a valid XML: #95

Open
karlrissland opened this issue Aug 24, 2022 · 1 comment

Comments

@karlrissland
Copy link

Bicep Code

param APIMName string

resource policyFragment2 'Microsoft.ApiManagement/service/policyFragments@2021-12-01-preview' = { 
  name: '${APIMName}/SetBasicAuthHeader'
  properties: {
    description: 'Sample desc'
    format: 'xml'
    value: './SetBasicAuthHeader.xml'
  }
}

Fragment
Simplified to bare minimum

<fragment>
</fragment>

CLI command to deploy

az deployment group create --resource-group APIM --template-file singlepolicyfragmentdeploy.bicep --parameters APIMName=karlrissapim

Error

{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"ValidationError\",\r\n \"message\": \"The policy fragment is not a valid XML: Data at the root level is invalid. Line 1, position 1.\",\r\n \"details\": null\r\n }\r\n}"}]}}

Additional Information
We tried deploying from an Azure Storage account in case it needed a URI to reference the policy fragment, failed with the same error message.

We manually created a policy fragment in the portal, then saved the configuration to the repository and cloned the repository locally to inspect the policy fragment to see if there was a documentation bug and the fragment structure was different, the repository does not contain policy fragments so we were unable to view.

We also tried both format types, XML and RawXML.

Lastly, we also compiled bicep to arm and tried again, receiving the same error message.

@brwilkinson
Copy link

brwilkinson commented Jun 3, 2023

had a similar question below and found an answer

    format: 'xml'
    value: loadTextContent('loadtextcontent/fragment-request-context-data.xml')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants