@Rourke, Fergus Thanks for reaching out. I tried the same inhouse and I was able to reproduce the issue. It seems to be an issue with Payload format: XML we need to change that to Payload format: rawxml there is no way to modify this in azure portal however, as a workaround you can use Postman to achieve this
Please replace the below values appropriately
PUT
https://management.azure.com/subscriptions/**{sub id}/resourceGroups/{Resource group name}/providers/Microsoft.ApiManagement/service/{Service Name}/policyFragments/{Fragment Name}**?api-version=2021-12-01-preview
Payload:
{"id":"/subscriptions/{sub id}/resourceGroups/{Resource group name}/providers/Microsoft.ApiManagement/service/{Service Name}/policyFragments/{Fragment Name}","type":"Microsoft.ApiManagement/service/policyFragments","name":"{Fragment Name}","properties":{"value":"<!--\n IMPORTANT:\n - Policy fragment are included as-is whenever they are referenced.\n - If using variables. Ensure they are setup before use.\n - Copy and paste your code here or simply start coding\n-->\n<fragment>\n <set-backend-service base-url=\"@(\"https://{ {serviceBusNamespace}}.servicebus.windows.net/\" + (string)context.Variables[\"queue\"] + \"/messages?api-version=2015-01\")\" />\n</fragment>\n","description":"","format":"rawxml"}}
you will get 202 Accepted response. Later you will see the policy fragment created in the azure portal.
We will create a work item to fix this bug, please try the above steps and let me know incase of further queries, I would be happy to assist you.
To benefit the community find the right answers, please do mark the post which was helpful by clicking on ‘Accept Answer’ & ‘Up-Vote’.