-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Error when API Management policy C# expression contains double quotes #9223
Comments
Please also note that the Azure API Management Extension in VSCode has the same behavior with regards to attribute values: When saving and updating a policy any single quote delimited attribute values will automatically be replaced with double quote delimited values. AFAICT using XML entities is at the moment the only feasible workaround. |
Looking at #4140 I get the impression that there is tests to make sure that policies containing "XML" like |
If I am not mistaken the problem is that the provider is transferring the data in |
The problem with #4140 is that it doesn't apply to the global API policy. The PR #9296 should fix that. |
This has been released in version 2.37.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example: provider "azurerm" {
version = "~> 2.37.0"
}
# ... other configuration ... |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_api_management
Terraform Configuration Files
The referenced
sandbox-policy.cshtml
looks something like this:Debug Output
https://gist.github.com/knutwannheden/380ed0fc78f0fc023cd831b2c9c789d6
Panic Output
Expected Behavior
It should be possible to use the same pseudo-XML content with Terraform as with the online Azure Portal editor.
Actual Behavior
Currently
terraform apply
appears to choke whenever a policy has an XML attribute value quoted using"
which itself also contains double quotes, but without encoding them using XML entities. So this does not work:It reports an error like the following:
Steps to Reproduce
terraform apply
Important Factoids
According to issue #3918 and the associated PR #4140 (see e.g. #4140 (comment)) I got the impression that the Terraform provider should be able to handle "XML" where the attribute values and content where XML characters like
<
,>
, and"
are not encoded using XML entities, just like also the editor in Azure Portal accepts it.To be honest I don't really understands how the Azure Portal does its parsing (well it isn't legal XML anyway), but it seems to work somehow and for the user experience I think it would be great it the same policy content could be provided via Terraform (i.e. without having to use XML entities).
As a workaround I was able to use single quotes to enclose the attribute value. But note that the Azure Portal online editor automatically converts them back to double quotes, so if that is copied back to the file used by Terraform it will break again.
References
The text was updated successfully, but these errors were encountered: