{"id":733,"date":"2014-09-11T16:42:00","date_gmt":"2014-09-11T16:42:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudioalm\/2014\/09\/11\/enhance-your-application-availability-monitoring-with-vs-2013-web-test-plugins\/"},"modified":"2022-05-26T06:04:24","modified_gmt":"2022-05-26T14:04:24","slug":"enhance-your-application-availability-monitoring-with-vs-2013-web-test-plugins","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/devops\/enhance-your-application-availability-monitoring-with-vs-2013-web-test-plugins\/","title":{"rendered":"Enhance your Application Availability Monitoring with VS 2013 Web Test Plugins"},"content":{"rendered":"<p>You may be aware Application Insights in Visual Studio Online provides you with the capability of monitoring the availability of your web applications through the use of <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms182536(v=vs.90).aspx\">Visual Studio Web Tests<\/a>. If not, you may want to take a peek at <a href=\"http:\/\/blogs.msdn.com\/b\/visualstudioalm\/archive\/2013\/11\/22\/using-a-visual-studio-web-test-for-availability-monitoring-in-application-insights.aspx\">this post<\/a> before continuing.<\/p>\n<p>Now, let\u2019s assume your application is a financial tool which provides real-time stock data. In order to effectively validate its availability, you need to pass in the current time somewhere in your web test request. After all, you want to make sure your data is current (you know, real-time data J )<\/p>\n<p>So, let\u2019s say that, after you record your web test in Visual Studio, you end up with the following web test request:<\/p>\n<p>\u00a0<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/1346.sampleRequest.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p>Clearly, you don\u2019t want the <strong>StartTime<\/strong> and <strong>EndTime<\/strong> query parameters to be static values. Rather, you want them to dynamically update for every run of the web test. Moreover, you want to generate two timestamps: one for current time, and another for 15 minutes before that.<\/p>\n<p>You might wonder, how do I do that?<\/p>\n<p>Well, one way is to convert your web test to a coded web test and dynamically generate the timestamps. But, if you\u2019re still reading this, you probably already know that coded web tests are not supported in Application Insights. All you get to upload to the Visual Studio Online portal is a .webtest file. No code or anything else for that matter.<\/p>\n<p>Now on to the good news!<\/p>\n<p>With the release of Visual Studio 2013, you now have the option to add Web Test Plug-ins out-of-the-box. Even more exciting, Application Insights now supports running web tests with Visual Studio 2013 plugins!\u00a0<\/p>\n<p>Here\u2019s the rundown:<\/p>\n<p>Click the \u201cAdd Web Test Plugin\u201d button (you could also use the request plugin instead):<\/p>\n<p>\u00a0<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/5280.addPluginButton.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u00a0VS 2013 ships with the following ready-to-use plugins:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/5100.pluginsList.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p>Surprisingly (or not), the first plugin available is exactly what will solve our problem here!<\/p>\n<p>\u00a0<\/p>\n<p>**Date Time Plugin **<\/p>\n<p>With this plugin, you give it an input time &#8211; or simply tell it to use the current time (plus or minus some number of days, hours, minutes or seconds) \u2013 specify the output format and you get back a nicely formatted timestamp in the specified Target Context Parameter.<\/p>\n<p>Nice, huh?<\/p>\n<p>So, to solve our problem, we add two such date time plugins, like the following:<\/p>\n<p>We need one for the current time, which we will save into the \u201cNow\u201d context parameter.<\/p>\n<p>\u00a0<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/6560.NowDateTime.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>And one for the time stamp of \u201c15 minutes ago\u201d. To accomplish this, we make use of the <strong>Add Minutes<\/strong> property. We, in fact, want to subtract 15 minutes from the current time, so all we need here is set <strong>Use Current Time<\/strong> to true and then specify \u201c-15\u201d for the <strong>Add Minutes<\/strong>. We will then save this to the \u201c15MinAgo\u201d context parameter.<\/p>\n<p>\u00a0<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/6131.15MinAgoDateTime.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>\u00a0<\/p>\n<p>There we have it!<\/p>\n<p>All the pieces we need are in place. Now, all that\u2019s left is to tie this in to the web test request and indicate we want to use our recently crafted context parameters.<\/p>\n<p>Here\u2019s the final web test request:<\/p>\n<p>\u00a0<img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/devops\/wp-content\/uploads\/sites\/6\/2014\/09\/2677.finalRequest.png\" alt=\"\" border=\"0\" \/><\/p>\n<p>As you can see, the way to refer to the context parameter is by using the double curly braces {{ }} notation.<\/p>\n<p>Now, for every run, you get dynamically generated timestamps. Neat!\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>With this, all you need is save your web test, upload it to the portal and enjoy!<\/p>\n<p>I hope you will try this out and give us feedback!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>You may be aware Application Insights in Visual Studio Online provides you with the capability of monitoring the availability of your web applications through the use of Visual Studio Web Tests. If not, you may want to take a peek at this post before continuing. Now, let\u2019s assume your application is a financial tool which [&hellip;]<\/p>\n","protected":false},"author":146,"featured_media":45953,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[224,226,1,252],"tags":[],"class_list":["post-733","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-ci","category-devops","category-testing"],"acf":[],"blog_post_summary":"<p>You may be aware Application Insights in Visual Studio Online provides you with the capability of monitoring the availability of your web applications through the use of Visual Studio Web Tests. If not, you may want to take a peek at this post before continuing. Now, let\u2019s assume your application is a financial tool which [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/users\/146"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/comments?post=733"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/posts\/733\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media\/45953"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/media?parent=733"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/categories?post=733"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/devops\/wp-json\/wp\/v2\/tags?post=733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}