gpt4 book ai didi

Azure Application Insights - 使用基本身份验证进行可用性测试?

转载 作者:行者123 更新时间:2023-12-04 16:10:31 25 4
gpt4 key购买 nike

我正在尝试使用 Azure Application Insights 设置可用性测试(URL Ping 测试)在需要基本身份验证的端点上。看来标准方法是 https://username:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f1f0e1c1c18001d0b2f02160a010b1f0006011b410c0002" rel="noreferrer noopener nofollow">[email protected]</a> Azure 不接受(错误消息表明 URL 格式错误,可能我在开头缺少 https/http)。

假设我想留在 Azure 生态系统中,除了使用多步骤 Web 测试或 Azure Functions 之外,还有其他方法可以实现此目的吗? :)

最佳答案

RFC 3986 已弃用在 URL 中传递基本身份验证凭据(这是 RFC 的片段)

3.2.1. User Information

The userinfo subcomponent may consist of a user name and,optionally, scheme-specific information about how to gainauthorization to access the resource. The user information, ifpresent, is followed by a commercial at-sign ("@") that delimits itfrom the host.

  userinfo    = *( unreserved / pct-encoded / sub-delims / ":" )

Use of the format "user:password" in the userinfo field is deprecated.

另一种方法是使用授权 header 来传递凭据。这是 Wikipedia (Basic Auth) 的片段关于如何构造此 header 。

The Authorization field is constructed as follows:[6]

  1. The username and password are combined with a single colon. (:)
  2. The resulting string is encoded into an octet sequence.[7]
  3. The resulting string is encoded using a variant of Base64.[8]
  4. The authorization method and a space is then prepended to the encoded string, separated with a space (e.g. "Basic ").

For example, if the browser uses Aladdin as the username and OpenSesame as the password, then the field's value is the base64-encoding of Aladdin:OpenSesame, or QWxhZGRpbjpPcGVuU2VzYW1l. Then the Authorization header will appear as:

Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l

您可以在 Visual Studio Enterprise 中创建一个Web 测试文件,然后将其上传到应用程序洞察中并使用该文件。请参阅此文档:https://learn.microsoft.com/en-us/azure/application-insights/app-insights-monitor-web-app-availability

  1. 在 Visual Studio Enterprise 中,您可以创建 WebTest 项目。
  2. 右键单击您的项目名称,然后选择添加请求enter image description here
  3. 现在右键单击链接并选择添加标题enter image description here
  4. 您可以根据您的要求添加 header 。 enter image description here
  5. 当您查看 .webtest 文件时,您将看到 header 部分已附加在请求下。
<Request>
<Headers>
<Header Name="Authorization" Value="Basic QWxhZGRpbjpPcGVuU2VzYW1l" />
</Headers>
</Request>

关于Azure Application Insights - 使用基本身份验证进行可用性测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45301904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com