OData的Azure API管理问题 [英] Azure API Management issue with OData

查看:80
本文介绍了OData的Azure API管理问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个OData v4 API,我们将其放在Azure API管理(AAM)服务的后面,但是在配置路由/操作时遇到了问题.简而言之,问题是除非明确配置AAM,否则AAM将拒绝对路由/操作的查询(您会收到404错误),但是对于OData,每个操作(端点)的每个属性(属性)都可以有一条路由).该问题很快变得难以控制.

We have an OData v4 API that we are putting behind an Azure API Management (AAM) service, but have run into a problem configuring the routes/oerations. In a nutshell, the issue is that AAM will reject a query for a route/operation unless it is explicitly configured (you get a 404 error), but with OData there can be a route for every attribute (property) of every operation (endpoint). The problem quickly becomes unmanageable.

OData允许您查询单个属性/属性(例如GET〜/api/Person(1234)/FirstName.如果将其放在AAM后面,则需要将其定义为一个操作.只要有仅其中的少数几个,但这潜在地意味着您必须快速定义成百上千的操作(除非我错过了一些事情).我们有一个包含35个顶级操作的API.每个资源平均有20个属性.即700我们需要定义一些操作,除了涉及的工作之外,这对于AAM开发人员门户网站的用户来说将是令人震惊的体验.

OData allows you to query an individual attribute/property (eg GET ~/api/Person(1234)/FirstName. If we put this behind AAM, we need to define it as an operation. That's OK as long as there are only a few of these, but it potentially means you quickly have to define hundreds/thousands of operations (unless I've missed something). We have an API with about 35 top level operations. Each resource has 20 attributes on average. That's 700 operations we would need to define. Apart from the work involved, that would be a shocking experience for users of the AAM developer portal.

我希望有人可以告诉我解决该问题的简便方法.我知道我可以编写这些脚本.如果您使用OData $ select查询参数(在此期间我也建议这样做),那么您在某种程度上也可以解决此问题.我无法克服我在这里错过了一些东西的感觉.是否可以为操作定义某种通配符部分(例如/Person/*)?我在AAM文档中找不到类似的内容.

I'm hoping someone can tell me an easy way to get around this problem. I know I can script the creation of these. You an also get around this problem to some degree if you use an OData $select query parameter (which is what I've suggested in the meantime). I can't get over the feeling I've missed something here. Is there a way of defining some sort of wildcard portion to the operation (eg /Person/*)? I can't find anything like that in the AAM documentation.

推荐答案

尝试使用URL模板而不是显式地编写它们,即以这种方式为/{entity}/{property}定义操作,以匹配每个实体和每个实体的每个属性.如果要在URL末尾捕获多个段,也可以使用通配符.

Try using URL templates instead of writing them explicitly, i.e. define operations for /{entity}/{property} this way it'll match every entity and every property of every entity. And you could use wildcards as well if you want to capture multiple segments at the end of URL.

这篇关于OData的Azure API管理问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆