测试特定的 Azure 网站实例

Testing specific Azure Web Site Instance(测试特定的 Azure 网站实例)
本文介绍了测试特定的 Azure 网站实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配置为使用多 (2) 个实例的 Azure 网站:

I have an Azure Web Site configured to use multiple (2) instances:

我有一个应该在实例之间传递消息(即缓存驱逐)的服务总线.我需要测试这个机制.

I have a service bus that should pass messages (ie Cache Evict) between the instances. I need to test this mechanism.

在传统(本地)系统中,我会将浏览器指向实例 1(即 http://myserver1.example.com),执行一个操作,然后将我的浏览器指向另一个实例(http://myserver2.example.com) 进行测试.

In a conventional (on premise) system I would point a browser to instance 1 (ie http://myserver1.example.com), perform an action, then point my browser to the other instance (http://myserver2.example.com) to test.

但是,在 Azure 中,我看不到访问特定实例的方法.是否可以?或者是否有另一种方法来运行此测试场景(对实例 1 采取行动,确保实例 2 行为正常)?

However, in Azure I can't see a way to hit a specific instance. Is it possible? Or is there an alternative way to to run through this test scenario (act on instance 1, ensure instance 2 behaves appropriately)?

推荐答案

不幸的是,没有官方的方法来做到这一点.但是,您可以通过在请求中设置一个名为 ARRAffinity 的 cookie 来实现.

Unfortunately, there isn't an official way of doing this. However, you can achieve that by setting a cookie called ARRAffinity on your request.

尝试从任何客户端(Chrome、Firefox、curl、httpie 等)访问您的站点并检查您返回的响应标头.

Try hitting your site from any client (Chrome, Firefox, curl, httpie, etc) and inspect the response headers that you are getting back.

例如在 curl 你会这样做

curl -I <siteName>.azurewebsites.net

你会得到这个

HTTP/1.1 200 OK
Content-Length: 2
Content-Type: text/html
Last-Modified: Wed, 17 Sep 2014 16:57:26 GMT
Accept-Ranges: bytes
ETag: "2ba0757598d2cf1:0"
Server: Microsoft-IIS/8.0
X-Powered-By: ASP.NET
Set-Cookie: ARRAffinity=<very long hash>; Path=/;Domain=<siteName>.azurewebsites.net
Date: Fri, 28 Nov 2014 03:13:07 GMT

您感兴趣的是 ARRAFinity 如果您发送几个请求,您会注意到哈希将在代表您的 2 个实例的 2 个值之间不断变化.

what you are interested in is the ARRAFinity if you send couple of request you would notice that hash will keep changing between 2 values that represent your 2 instances.

在您的请求的 Cookie 标头中设置它会保证它转到其中一个实例而不是另一个实例.

Set that in your Cookie header on your request will guarantee it going to one of the instances and not the other.

curl --cookie ARRAfinity=<one of the hashes you got> <siteName>.azurewebsites.net

这篇关于测试特定的 Azure 网站实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
how do i pass parameters to aspnet reportviewer(如何将参数传递给aspnet report查看器)
Bind multiple parameters from route and body to a model in ASP.NET Core(在ASP.NET Core中将路由和主体中的多个参数绑定到一个模型)
Custom model binding in AspNet Core WebApi?(AspNet Core WebApi中的自定义模型绑定?)
How to minify in .net core mvc view?(如何在.Net核心MVC视图中缩小?)