ユーザのJwtクレームデータに基づいてAzure APIポリシー属性を設定できるようにしたいと思います。 counter-keyやincrement-conditionなどの文字列値を設定できましたが、すべての属性を設定することはできません。私は、次のような何かやって想像:Azure APIMポリシーエディタ
<rate-limit-by-key
calls="@((int) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/LimitRate/Limit", "5"))"
renewal-period="@((int) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/LimitRate/Duration/InSeconds", "60"))"
counter-key="@((string)context.Variables["Subject"])"
increment-condition="@(context.Response.StatusCode == 200)"
/>
をしかし、私は次のエラーを取得するよう、私はポリシーを保存するときに起こっていくつかの検証があるようです:
Error in element 'rate-limit-by-key' on line 98, column 10: The 'calls' attribute is invalid - The value '@((int) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/LimitRate/Limit", "5"))' is invalid according to its datatype 'http://www.w3.org/2001/XMLSchema:int' - The string '@((int) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/LimitRate/Limit", "5"))' is not a valid Int32 value.
私もトラブルの文字列パラメータを設定することがあります私が試してみて、ポリシーを保存する場合は、以下を提供します
<quota-by-key
calls="10"
bandwidth="100"
renewal-period="@((string) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/Quota/RenewalPeriod", "P00Y00M01DT00H00M00S"))"
counter-key="@((string)context.Variables["Subject"])"
/>
(厳格な形式の1はあるが):
Error in element 'quota-by-key' on line 99, column 6: @((string) context.Variables["IdentityToken"].AsJwt().Claims.GetValueOrDefault("/Quota/RenewalPeriod", "P00Y00M01DT00H00M00S")) is not in a valid format. Provide number of seconds or use 'PxYxMxDTxHxMxS' format where 'x' is a number.
私は、文字列ではなく、{return 5}、@(5)などの主張のコンビネーションの大きなセットを試しましたが、保存時にいくつかの検証が行われているようですそれを止める。
私のAPIに追加するのは便利な機能だと思うので、この問題はありませんか?