标签: azure-api-management

在Azure API Management中,我可以使用subscription-key作为Request标头的一部分而不是Query字符串参数吗?

我正在将服务迁移到Azure API Management.此服务是从移动设备(本机应用程序)调用的.问题是,将订阅密钥附加到查询字符串可能需要更长时间才能更新应用程序,而不仅仅是在请求标头中使用它.

那么它可以在那里使用吗?

azure azure-api-management

6
推荐指数
2
解决办法
6986
查看次数

在本地开发 Azure 函数

我领导着一个庞大的 azure 函数开发团队。因此,Microsoft 引用的大多数使用 azure Web 界面的示例对我都不起作用。我正在使用模拟器在本地开发 Azure 函数以节省一些成本。我通过 Visual Studio 将所有功能发布到我的集成环境中。

我正在开发一堆需要 api 网关来处理使用 Azure AD B2C 的身份验证工作流的 azure 函数。现在,没有可以在本地运行的 api 网关模拟器或 Azure AD B2C 模拟器。我的身份验证工作流程涉及拦截对 api 的请求,将它们重定向到 AD B2C 进行身份验证,随后将 auth-token 添加到 http 标头,然后调用 http 触发的 azure 函数。

现在,问题变成了,我如何测试身份验证工作流程?如何设置 api 网关以将我在 Visual Studio 中本地运行的函数注册为云中 api 网关的 api 端点?

restful-authentication azure azure-api-management azure-ad-b2c azure-functions

6
推荐指数
2
解决办法
1314
查看次数

UriTemplate 中使用的 Azure API 管理模板参数必须在 Operation 中定义,反之亦然

我有许多 Azure 函数,现在我想将 Azure API 管理放在前面。

我已经从我帐户中的 2 或 3 个其他函数应用程序中导入了所有函数,没有任何问题,但我在使用其中一个函数应用程序时遇到了问题。这个功能应用有6个功能,其中3个如果我专门选择可以导入。其他 3 个函数中的某些内容引发错误:

All template parameters used in the UriTemplate must be defined in the Operation, and vice-versa.

这里是 Azure 函数本身创建的我的 Swagger api 文档的相关部分:

    paths:
'/api/api-keys/{customerId}':
    delete:
    operationId: '/api/api-keys/{customerId}/delete'
    produces: []
    consumes: []
    parameters:
        - name: customerId
        in: path
        required: true
        type: string
    description: >-
        Replace with Operation Object
        #http://swagger.io/specification/#operationObject
    responses:
        '200':
        description: Success operation
    security:
        - apikeyQuery: []
'/api/api-keys/{customerId}/{apiKeyId}':
    delete:
    operationId: '/api/api-keys/{customerId}/{apiKeyId}/delete'
    produces: []
    consumes: []
    parameters:
        - name: …
Run Code Online (Sandbox Code Playgroud)

azure swagger azure-api-management azure-functions

6
推荐指数
2
解决办法
4158
查看次数

使用应用程序网关方案在 Azure API 管理中保留客户端 IP 地址

我在此设置中配置了 Azure 应用程序网关API 管理https://docs.microsoft.com/en-us/azure/api-management/api-management-howto-integrate-internal-vnet-appgateway - 应用程序网关是公共端点和仅定义的路由传递到 API 管理。

我想使用该ip-filter策略来限制对某些 IP 地址的调用。但是,当呼叫通过应用程序网关传入时,原始客户端 IP 地址将丢失或混淆为 IP 0.0.0.0

有没有办法保留原始客户端 IP 地址并将其从应用程序网关传递到 API 管理?

azure-api-management azure-application-gateway

6
推荐指数
1
解决办法
3345
查看次数

导出/导入 Azure API 管理开发人员门户配置

Microsoft 发布了一个新的Azure API管理开发人员门户。

我正在寻找一种从API开发人员门户导出所有文件和配置并能够将其导入另一个的方法。因此,我可以将相同的自定义应用于我的所有APIM实例。

有没有办法做到这一点?

azure-api-management apim

6
推荐指数
1
解决办法
1073
查看次数

Azure API 管理提供的 API 网关和 Azure 应用程序网关有什么区别?

我是 Azure 的新手,我浏览了 Azure 官方文档。

  • 我想了解的是Azure API Management 提供的API Gateway 和Azure Application Gateway 的区别和相似之处?

  • 什么时候需要在API Gateway(API管理提供)前面加上Application Gateway?

    • 当 API Gateway 正常托管时。
    • 当 API 网关托管在 VNet 中时。
  • 我们什么时候需要在应用程序网关前面使用 Azure Front Door?

  • 我们需要在什么场景下链接Azure Front Door --> Application Gateway --> API Gateway,而不是我们不能这样做Azure Front Door --> API Gateway,如果是在什么场景下?

我想根据以下两个计算解决方案了解上述问题的解决方案:

  • 当我的 API 托管在容器中时。
  • 当我的 API 仅由 Azure Functions 组成时。

azure azure-api-management microservices azure-application-gateway azure-front-door

6
推荐指数
1
解决办法
3636
查看次数

Azure 门户:API 管理检查客户端证书

是否可以根据 API Manager 客户端证书存储中的证书检查通过 GET https API 调用发送的客户端证书?

在 Azure 门户中,只能使用私钥和密码上传客户端证书。但是,客户端永远不会将其证书的私钥部分与密码一起发送。

当我尝试上传仅包含公钥的客户端证书时,Azure 出现错误。

根据Azure门户API管理文档,应该是可能的: https://learn.microsoft.com/en-us/azure/api-management/api-management-howto-mutual-certificates-for-clients

api certificate azure azure-api-management azureportal

5
推荐指数
1
解决办法
4685
查看次数

Azure 应用程序网关未传递客户端证书

我已经拿起了别人设置的东西。我们有一个 API 管理实例,位于应用程序网关后面,它具有 API 策略:

<inbound>
        <choose>
            <when condition="@(context.Request.Certificate == null)">
                <return-response>
                    <set-status code="403" reason="Client certificate required..d1PD" />
                </return-response>
            </when>
        </choose>
        <choose>
            <when condition="@(!context.Request.Certificate.Verify())">
                <return-response>
                    <set-status code="403" reason="Client certificate cannot be verified..d2PD " />
                </return-response>
            </when>
        </choose>
        <choose>
            <when condition="@(!context.Deployment.Certificates.Any(c => c.Value.Thumbprint == context.Request.Certificate.Thumbprint))">
                <return-response>
                    <set-status code="403" reason="Client certificate is untrusted or invalid..d3PD" />
                </return-response>
            </when>
        </choose>
        <base />
    </inbound>
Run Code Online (Sandbox Code Playgroud)

在邮递员中,我正在传递证书和密钥。邮递员控制台显示

Client Certificate:
keyPath:"C:\selfsigned\internalscm.X.com.key"
pemPath:"C:\selfsigned\internalscm.X.com.crt"
pfxPath:""
Run Code Online (Sandbox Code Playgroud)

我正在传递Ocp-Apim-Trace请求的标头,因此我得到了包含以下内容的跟踪:

traceEntries        {2}
  inbound       [10]
..
    6       {4}
        source  :   authentication-certificate
        timestamp …
Run Code Online (Sandbox Code Playgroud)

ssl azure azure-api-management

5
推荐指数
1
解决办法
5773
查看次数

Azure API 管理“无法完成请求。请稍后重试。”

每当我尝试测试 API(使用 API 刀片的“测试”选项卡)时,我都会得到 Could not complete the request. Please try again later.

我的 API 管理服务上已经发生这种情况至少两个小时了。我创建了一个额外的 API 管理服务和另一个订阅(带有自己的 APIM)。

我处于消费层(SLA 为 99.9%),Azure 状态页面全面显示绿色。我自己的个人仪表板(服务运行状况)正在显示No service issues found

这让我认为这是我所做的事情。

我该如何着手调查此事?

azure azure-api-management

5
推荐指数
1
解决办法
5933
查看次数

在策略定义中返回响应时如何使用变量?

我正在 Azure API 管理的实例中配置入站策略。

首先,我设置一个变量:

<set-variable name="var1" value="" />
Run Code Online (Sandbox Code Playgroud)

然后我发送一个请求

<send-request mode="new" response-variable-name="var1" timeout="20" ignore-error="false">
Run Code Online (Sandbox Code Playgroud)

它返回一个 JSON。测试时,我在跟踪选项卡中收到以下消息:

已发送对“ https://my-api.azure-api.net/api/data ”的 GET 请求,结果存储在“var1”变量中。

我猜发送请求策略有效并且结果存储在变量中。然后我想返回一个响应(仍在入站中,当尝试在出站中执行此操作时,我得到 500):

<return-response response-variable-name="existing response variable">
    <set-status code="200" reason="OK" />
    <set-header name="Content-Type" exists-action="override">
        <value>application/json</value>
    </set-header>
    <set-body>
    {
        "success": true,
        "var1": context.Variables["var1"]
    }
    </set-body>
</return-response>
Run Code Online (Sandbox Code Playgroud)

我的问题是它不起作用......它只是渲染context.Variables["var1"]

也是如此:

  • @context.Variables["var1"]
  • @{ context.Variables.GetValueOrDefault<string>("var1") }
  • @context.Variables.GetValueOrDefault("var1")

所有这些都按书面形式呈现,没有提取任何价值。

编辑:我还尝试添加占位符字符串,然后使用

<find-and-replace from="Placeholder" to="context.Variables.GetValueOrDefault("var1")" />
Run Code Online (Sandbox Code Playgroud)

并尝试将其放置在入站和出站中。但这一政策并未推出。

这是一个 JSON 对象,我想将其附加到响应中(小细节:实际上我遇到了多个变量的问题)。

我的问题是:如何将声明的变量添加到响应中?

string-concatenation azure azure-api-management

5
推荐指数
1
解决办法
3万
查看次数