- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 APIM 中有一个包含不同操作的 API。其中一项操作称为例如测试操作
testOp
将发送给它的请求转发到 azure 中的函数应用 (FA)。我决定将其写入名为 fa-url
的命名值中,而不是在策略中显式写入 FA URL。所以 API 策略如下所示:
<policies>
<inbound>
<base />
<set-backend-service base-url="{{fa-url}}" />
<rewrite-uri template="/" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
此命名值是通过 ARM 模板创建的,该模板将此命名值的值设置为 FA 的触发 URL。这是ARM代码:
{
"properties": {
"tags": [],
"secret": true,
"displayName": "fa-url",
"value": "[listsecrets(resourceId(parameters('faRG'), 'Microsoft.Web/sites/functions', parameters('functionAppName'), parameters('functionName')), variables('apiFuncApp')).trigger_url]"
},
"name": "[concat(parameters('ApimServiceName'), '/fa-url')]",
"type": "Microsoft.ApiManagement/service/namedValues",
"apiVersion": "2021-01-01-preview"
},
此 Arm 模板和命名值将生成一个类似于以下内容的 URL:
https://fa-name.xx.companything.net/api/realFunctionname?code=123456=
因此,该 url 以查询参数结尾,该参数以等号结尾。现在的问题是:这个 API 操作 (testOp
) 在其定义中有一个 URL
testOp 看起来与此类似:
因此,当我尝试通过此操作向 FA 发送请求时,收到 404 Not Found
或 401 Unauthorized
错误。经过检查跟踪,原因基本上是因为重写 URL 在 fa URL 末尾添加了“/”。所以不要发送到:
https://fa-name.xx.companything.net/api/realFunctionname?code=123456=
它发送到
https://fa-name.xx.companything.net/api/realFunctionname?code=123456=/
如果我删除了重写 URL 功能,我仍然会收到错误,因为现在它将发送到:
https://fa-name.xx.companything.net/api/realFunctionname?code=123456=/testOp
有什么方法可以防止在后端 URL 中添加任何后缀吗?或者您有其他建议来解决这个问题吗?
注意:我还尝试将重写 URL 设置为空字符串,但当我这样做时,azure 拒绝保存策略。
最佳答案
好吧,看来我唯一需要做的就是使用这个重写策略:
<rewrite-uri template="?" />
这将使 URL 看起来完全符合我的要求,即:
https://fa-name.xx.companything.net/api/realFunctionname?code=123456=
关于Azure APIM重写url以没有后缀url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73830789/
在我的 azure devops 管道中,我有一个任务 AzureCLI@2,它将 api 部署到 apim。我如何使用 az apim api 来执行相同的任务更新api?我知道有一个操作可以做到这
我理解当请求包含 Ocp-Apim-Trace: true 时,如下所示: GET /api/v1/BotConfig HTTP/1.1 Host: xyz.azure-api.net Cache-C
我理解当请求包含 Ocp-Apim-Trace: true 时,如下所示: GET /api/v1/BotConfig HTTP/1.1 Host: xyz.azure-api.net Cache-C
我已经创建了 web api 并尝试使用 c# 发出 GET 请求,如下所示 namespace APIMCheck { class Program { static void Main(
我想在 Azure API 管理策略中实现客户端证书验证,以检查客户端是否具有有效证书(按照以下文档)。 https://learn.microsoft.com/en-us/azure/api-man
我有一个带有自定义域和多个 API 的 azure APIM,如下面的屏幕截图所示:- 每个 API 下都有多个端点,并且所有端点都具有相同的主机名。自定义域级别有一个协商客户端证书 设置,我只想为其
我最近将 APIM 实例从开发人员层更改为消费层,并且在验证内容策略中看到了一些奇怪的行为。在开发人员层,此策略将按预期工作并返回 400 错误以及相应的错误消息。 以下是政策: 下面是来
我目前仍在 APIM 中探索。我在有效负载 #1 中有一个有效负载,我想将其转换为另一个有效负载 #2(预期)。 我将如何编辑我的策略来构建此有效负载? 有效负载1 { "dependtee_
我正在尝试通过 APIM 将文件批量上传到 Azure 存储帐户。在本地,我可以使用 REST API 将文件上传到 azure 存储帐户。但是,通过 APIM 我无法上传文件。我收到 401 错误。
在我的口腔中,我有查询参数调用“PageSize”,我需要检查用户输入情况比较严重,需要向用户显示消息 比我在出站部分中放置的 = 20">
来自Azure API management pricing page我发现除了开发人员层和高级层之外,不支持虚拟网络。 目前,在配置 APIM 的 VN 时,我的开发人员级别订阅可以在“关闭”、“外
我在 Azure API 管理中有以下策略。这样就可以正常工作了: @{ try { // ... doing something
我正在尝试通过 Azure APIM 访问本地 API。如果我使用 VNET 和 VPN 隧道,我可以访问 On-Prem API,但是,这不是一个理想的解决方案。我正在尝试让混合连接(端口桥)以相同
有没有办法将通过 APIM 请求传入的查询参数作为路径参数传递给后端服务调用?例如: 对于以下 API 调用 base_url/a/{pathParam1}?query=Qvalue 我想将 URL
目前我已经创建了一个 Azure APIM 实例,URL 如下所示。 https://abc-test.azure-api.net 我想使用此 APIM 实例来支持开发和 QA 环境。所以我想设置如下
我正在尝试处理后端 API(REST),没有可通过 Azure APIM 访问的 swagger 文档。我希望所有调用都定向到后端 API,而不是为所有资源手动创建 GET/PUT/POST。我的所有
来自Azure API management pricing page我发现除了开发人员层和高级层之外,不支持虚拟网络。 目前,在配置 APIM 的 VN 时,我的开发人员级别订阅可以在“关闭”、“外
我在 Azure API 管理中有以下策略。这样就可以正常工作了: @{ try { // ... doing something
我正在尝试通过 Azure APIM 访问本地 API。如果我使用 VNET 和 VPN 隧道,我可以访问 On-Prem API,但是,这不是一个理想的解决方案。我正在尝试让混合连接(端口桥)以相同
有没有办法将通过 APIM 请求传入的查询参数作为路径参数传递给后端服务调用?例如: 对于以下 API 调用 base_url/a/{pathParam1}?query=Qvalue 我想将 URL
我是一名优秀的程序员,十分优秀!