I have a problem reusing APIM expression.
Specificially, a named value below is created like above,
name
JWTValidator
@(
@"<validate-jwt header-name='Authorization' failed-validation-httpcode='401' failed-validation-error-message='Error: expired token or invalid token' require-expiration-time='true' require-scheme='Bearer' require-signed-tokens='true'>
<openid-config url='xxx' />
<audiences>
<audience>xxx</audience>
</audiences>
<issuers>
<issuer>https://xxx</issuer>
</issuers>
</validate-jwt>"
)
and the policy below:
<policies>
<inbound>
<base />
{{JWTValidator}}
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
However, the policy element is removed and not inserted.
Any idea?
Is there a better way to reusing policy?
Upate
I want to define JWTValidator
as Named value, and use it on Product level if possible, otherwise, API level.
Upate 2
I have changed to below, however, {{JWTValidator}}
is auto-removed when it is saved.
Please note that the value of JWTValidator
is saved successfully, which might mean the syntax is correct.
<policies>
<inbound>
{{JWTValidator}}
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-properties
https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions