{"id":5086,"date":"2015-11-12T00:00:00","date_gmt":"2015-11-12T00:00:00","guid":{"rendered":"https:\/\/azure.microsoft.com\/blog\/creating-a-web-test-alert-programmatically-with-application-insights"},"modified":"2025-09-18T08:28:38","modified_gmt":"2025-09-18T15:28:38","slug":"creating-a-web-test-alert-programmatically-with-application-insights","status":"publish","type":"post","link":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/","title":{"rendered":"Creating an Application Insights Web Test and Alert Programmatically"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Availability checking and Alerting are features of Application Insights. Application Insight\u2019s web tests will ping your application from multiple locations to check availability and then alert you when it is down. In today\u2019s highly connected world the cost of an outage is very high and visible: users expect 100% availability and high performance. You can manually <a href=\"https:\/\/azure.microsoft.com\/documentation\/articles\/app-insights-monitor-web-app-availability\/\">set up web tests<\/a> in the Azure Portal. But if you deploy your application automatically, manual configuration may not be an option. In this post I will explain how to deploy a web test automatically.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We\u2019ll create a template from a manually-created web test, and then use it to automate the creation of future web tests.&nbsp; So we\u2019ll start by creating a web test manually.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"creating-a-web-test\">Creating a web test<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to your application resource in the Azure Portal, click the Availability tile and then Add web test. Then specify all the details of your test. <a href=\"https:\/\/azure.microsoft.com\/documentation\/articles\/app-insights-monitor-web-app-availability\/\">Read more about web tests<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\" alt=\"1\" title=\"1\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"exporting-the-alert-and-web-test-resources\">Exporting the Alert and Web Test Resources<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">Navigate to <a href=\"https:\/\/resources.azure.com\/\">Azure Resource Explorer<\/a>, where you can see all the resources in your subscription, including the resources generated when you created the web test. In Resource Explorer, open your subscription and resource group, then <strong>providers, Microsoft Insights<\/strong>. There you\u2019ll see two folders that will be important to us today: <strong>webtests<\/strong> and <strong>alertrules<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/42ade874-4961-4e75-b0a8-3d19f6727e63.webp\" alt=\"webtest-webapplication screenshot\" title=\"2\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When we created a web test manually, two resources were created: the web test resource and the alert resource. These resources are represented in Azure Resource Explore as JSON files.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Save these files locally to help prepare the template that generates web tests automatically.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"alert-rules-resource\">Alert Rules Resource<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/862f597b-edd7-47ac-a94a-91d96ac55f53.webp\" alt=\"alert rules screenshot\" title=\"3\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"web-test-resource\">Web Test Resource<\/h3>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/3b996ee0-cc34-488d-8752-03f657a9f981.webp\" alt=\"webtests screenshot of code\" title=\"4\" \/><\/figure>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"azure-resource-manager\">Azure Resource Manager<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">With <a href=\"https:\/\/azure.microsoft.com\/documentation\/articles\/powershell-azure-resource-manager\/\">Azure Resource Manager<\/a> (ARM) you can deploy a group of Azure resources together. You can make a template of a resource group that contains all the resources you need for the availability test. After creating your resource group, you can manage and deploy the entire group as a logical unit. All Application Insights assets, including web tests, can be managed by ARM.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"make-templates-from-the-json-files\">Make templates from the JSON files<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">After saving the two resources as separate JSON files you will need to make a few adjustments. Looking at the documentation page for Azure Resource Manger you can see an <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/powershell-azure-resource-manager\/#create-your-template\">example template<\/a>. We will use this example template plus our two JSON files to make our master template.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In your new JSON file put this outline:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n{\n    \"$schema\": \"https:\/\/schema.management.azure.com\/schemas\/2015-01-01\/deploymentTemplate.json#\",\n    \"contentVersion\": \"1.0.0.0\",\n    \"parameters\": {\n        \"webTestName\": { \"type\": \"string\" },\n        \"appName\": { \"type\": \"string\" },\n        \"URL\": { \"type\": \"string\" }\n    },\n    \"variables\": {\n        \"alertRuleName\": \"[concat(parameters('webTestName'), '-', toLower(parameters('appName')), '-', subscription().subscriptionId)]\"\n    },\n    \"resources\": [\n        {\n            \/\/web test JSON file contents\n        },\n        {\n            \/\/alert rule JSON file contents\n        }\n        \/\/Don't forget to close your brackets\n    ]\n}\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">\u00a0In addition, there will likely be multiple items that need to be changed in the template based on the application. The template has a <strong>parameters<\/strong> section so you can pass URL, Application Name, and Web Test name as parameters to the JSON template. Using parameters and variables will let us automate setting multiple names.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I will cover a few items you will need to change using these parameters. Depending on your specific case you will likely need to change other items which may include adding additional parameters and variables.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Id: You will need to set \u201cid\u201d for both resources. Here we use the resourceId helper function that creates the long path we are replacing using the webTestName parameter we defined at the top of the file.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\"id\": \"[resourceId('Microsoft.Insights\/webtests', parameters('webTestName'))]\",\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\"id\": \"[resourceId('Microsoft.Insights\/alertrules', variables('alertRuleName'))]\",\n<\/pre><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Web Test Name: In your webtest resource there are multiple locations where \u201cname\u201d is set.\u00a0<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>\"name\": \"[parameters('webTestName')]\",<br>\"SyntheticMonitorId\": \"[parameters('webTestName')]\"<\/code><\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Web Test Name: In your webtest resource there are multiple locations where \u201cname\u201d is set.\u00a0<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>\"name\": \"[parameters('webTestName')]\",<br>\"SyntheticMonitorId\": \"[parameters('webTestName')]\"<\/code><\/p>\n<\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>\"name\": \"[variables('alertRuleName')]\",<\/code><\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Hidden links: We need to replace the hidden links with helper functions. This will allow us to parameterize.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><code>\"tags\": {<br>\"[concat('hidden-link:', resourceId('Microsoft.Insights\/components', parameters('appName')))]\": \"Resource\"<br>},<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>\"tags\": {<br>\"[concat('hidden-link:', resourceId('Microsoft.Insights\/components', parameters('appName')))]\": \"Resource\",<br>\"[concat('hidden-link:', resourceId('Microsoft.Insights\/webtests', concat(parameters('webTestName'), '-', toLower(parameters('appName')))))]\": \"Resource\"<br>},<\/code><\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">In webtest.json Configuration{}\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Convert the Configuration.WebTest string into a concat function. This will allow us to include variables and parameters instead of hard coded values.\u00a0 For example, to replace URL and Name it would look like the following:<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">&#8220;WebTest&#8221;: &#8220;[concat(&#8221;)]&#8221;<\/p>\n<\/blockquote>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Parse Dependent Request and Expected Http Status Code are set in this string as well. They can be parameterized in a similar fashion.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Learn more about parameters and variables&nbsp;<a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/resource-group-authoring-templates\/\">here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>This is not an exhaustive list, the complete list depends on your application.<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Lastly, insert the apiVersion after the name tag in every resource.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In my template it looks like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n\"id\": \"[resourceId('Microsoft.Insights\/webtests', parameters('webTestName'))]\",\n\"name\": \"[parameters('webTestName')]\",\n\"apiVersion\": \"2014-04-01\",\n<\/pre><\/div>\n\n\n<h1 class=\"wp-block-heading\" id=\"create-a-web-test-with-microsoft-azure-powershell\">Create a Web Test with Microsoft Azure PowerShell<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">After saving the resources as JSON files, open Microsoft Azure PowerShell.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Login to your Azure account.<\/li>\n\n\n\n<li class=\"wp-block-list-item\">To login to your Azure account, use the <strong>Login-AzureRmAccount<\/strong> cmdlet. In versions of Azure PowerShell prior to 1.0 Preview, use the <strong>Add-AzureAccount<\/strong> command.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nPS C:temp> New-AzureRMResourceGroupDeployment -ResourceGroupName  Default-ApplicationInsights-CentralUS -webTestName myWebTest -appName WebApplication4 -URL https:\/\/WebApplication4.azurewebsites.net -templatefile .webTestTemplate.json\n<\/pre><\/div>\n\n\n<p class=\"wp-block-paragraph\">The parameters are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">ResourceGroupName: The name of the resource group in which to create your web test. If you are already monitoring your application, you\u2019ll want to use the same group as the Application Insights resource.<\/li>\n\n\n\n<li class=\"wp-block-list-item\">webTestName: The name you want to give the new web test.<\/li>\n\n\n\n<li class=\"wp-block-list-item\">appName: The name of your web application where you want to apply the web test.<\/li>\n\n\n\n<li class=\"wp-block-list-item\">URL: The URL to your web application.<\/li>\n\n\n\n<li class=\"wp-block-list-item\">templatefile: The name of the JSON file we just created.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> webTestName, appName, and URL are parameters we created in the JSON file that are automatically parsed and used in PowerShell.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now you can see your new web test in the <a href=\"https:\/\/portal.azure.com\/\">Azure Portal<\/a>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"use-your-templates\">Use your templates<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">You can use your templates with PowerShell and with <a href=\"https:\/\/blogs.msdn.com\/b\/webdev\/archive\/2015\/09\/16\/deploy-to-azure-from-github-with-application-insights.aspx\">GitHub integration<\/a>.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"please-let-us-know\">Please let us know\u2026<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">The Application Insights team is committed to providing quality tools for developers. We would greatly appreciate any feedback or new feature recommendations.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ms_queue_id":[],"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","_alt_title":"","footnotes":"","msx_community_cta_settings":[]},"categories":[1456,1482],"tags":[],"audience":[3054,3055,3053,3056],"content-type":[],"product":[1533],"tech-community":[],"topic":[],"coauthors":[1083],"class_list":["post-5086","post","type-post","status-publish","format-standard","hentry","category-devops","category-management-and-governance","audience-business-decision-makers","audience-developers","audience-it-decision-makers","audience-it-implementors","product-azure-monitor","review-flag-1680286580-543","review-flag-1680286581-295","review-flag-1680286584-658","review-flag-1-1680286581-825","review-flag-new-1680286579-546"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog<\/title>\n<meta name=\"description\" content=\"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog\" \/>\n<meta property=\"og:description\" content=\"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\" \/>\n<meta property=\"og:site_name\" content=\"Microsoft Azure Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/microsoftazure\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-12T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-09-18T15:28:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\" \/>\n<meta name=\"author\" content=\"Beckylin Orooji\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@azure\" \/>\n<meta name=\"twitter:site\" content=\"@azure\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Beckylin Orooji\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\"},\"author\":[{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/beckylin-orooji\/\",\"@type\":\"Person\",\"@name\":\"Beckylin Orooji\"}],\"headline\":\"Creating an Application Insights Web Test and Alert Programmatically\",\"datePublished\":\"2015-11-12T00:00:00+00:00\",\"dateModified\":\"2025-09-18T15:28:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\"},\"wordCount\":885,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\",\"articleSection\":[\"DevOps\",\"Management and governance\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\",\"name\":\"Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog\",\"isPartOf\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\",\"datePublished\":\"2015-11-12T00:00:00+00:00\",\"dateModified\":\"2025-09-18T15:28:38+00:00\",\"description\":\"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.\",\"breadcrumb\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Blog home\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Creating an Application Insights Web Test and Alert Programmatically\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#website\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"name\":\"Microsoft Azure Blog\",\"description\":\"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.\",\"publisher\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization\",\"name\":\"Microsoft Azure Blog\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"contentUrl\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp\",\"width\":512,\"height\":512,\"caption\":\"Microsoft Azure Blog\"},\"image\":{\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/microsoftazure\",\"https:\/\/x.com\/azure\",\"https:\/\/www.instagram.com\/microsoftdeveloper\/\",\"https:\/\/www.linkedin.com\/company\/16188386\",\"https:\/\/www.youtube.com\/user\/windowsazure\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117\",\"name\":\"shakir\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g\",\"caption\":\"shakir\"},\"sameAs\":[\"https:\/\/azure.microsoft.com\"],\"url\":\"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog","description":"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/","og_locale":"en_US","og_type":"article","og_title":"Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog","og_description":"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.","og_url":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/","og_site_name":"Microsoft Azure Blog","article_publisher":"https:\/\/www.facebook.com\/microsoftazure","article_published_time":"2015-11-12T00:00:00+00:00","article_modified_time":"2025-09-18T15:28:38+00:00","og_image":[{"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp","type":"","width":"","height":""}],"author":"Beckylin Orooji","twitter_card":"summary_large_image","twitter_creator":"@azure","twitter_site":"@azure","twitter_misc":{"Written by":"Beckylin Orooji","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#article","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/"},"author":[{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/beckylin-orooji\/","@type":"Person","@name":"Beckylin Orooji"}],"headline":"Creating an Application Insights Web Test and Alert Programmatically","datePublished":"2015-11-12T00:00:00+00:00","dateModified":"2025-09-18T15:28:38+00:00","mainEntityOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/"},"wordCount":885,"commentCount":0,"publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp","articleSection":["DevOps","Management and governance"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/","name":"Creating an Application Insights Web Test and Alert Programmatically | Microsoft Azure Blog","isPartOf":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage"},"thumbnailUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp","datePublished":"2015-11-12T00:00:00+00:00","dateModified":"2025-09-18T15:28:38+00:00","description":"Application Insights web tests will ping your application from multiple locations to check availability and then alert you when it is down. In this post I will explain how to automatically deploy a web test.","breadcrumb":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#primaryimage","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2015\/11\/61676d03-e10b-4b60-84ff-db295c7c48a3.webp"},{"@type":"BreadcrumbList","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/creating-a-web-test-alert-programmatically-with-application-insights\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog home","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/azure.microsoft.com\/en-us\/blog\/category\/devops\/"},{"@type":"ListItem","position":3,"name":"Creating an Application Insights Web Test and Alert Programmatically"}]},{"@type":"WebSite","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#website","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","name":"Microsoft Azure Blog","description":"Get the latest Azure news, updates, and announcements from the Azure blog. From product updates to hot topics, hear from the Azure experts.","publisher":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/azure.microsoft.com\/en-us\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#organization","name":"Microsoft Azure Blog","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","contentUrl":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-content\/uploads\/2024\/06\/microsoft_logo.webp","width":512,"height":512,"caption":"Microsoft Azure Blog"},"image":{"@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/microsoftazure","https:\/\/x.com\/azure","https:\/\/www.instagram.com\/microsoftdeveloper\/","https:\/\/www.linkedin.com\/company\/16188386","https:\/\/www.youtube.com\/user\/windowsazure"]},{"@type":"Person","@id":"https:\/\/azure.microsoft.com\/en-us\/blog\/#\/schema\/person\/c702e5edd662b328b49b7e1180cab117","name":"shakir","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g7664e653ea371ce16eaf75e9fa8952c4","url":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9342c7c05bb16548741bc5cd3a3e3b7ee0c8e746844ad2cc582db5beb5514c6f?s=96&d=mm&r=g","caption":"shakir"},"sameAs":["https:\/\/azure.microsoft.com"],"url":"https:\/\/azure.microsoft.com\/en-us\/blog\/author\/shakir\/"}]}},"msxcm_display_generated_audio":false,"msxcm_animated_featured_image":null,"distributor_meta":false,"distributor_terms":false,"distributor_media":false,"distributor_original_site_name":"Microsoft Azure Blog","distributor_original_site_url":"https:\/\/azure.microsoft.com\/en-us\/blog","push-errors":false,"_links":{"self":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/5086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/comments?post=5086"}],"version-history":[{"count":3,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/5086\/revisions"}],"predecessor-version":[{"id":46585,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/posts\/5086\/revisions\/46585"}],"wp:attachment":[{"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/media?parent=5086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/categories?post=5086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tags?post=5086"},{"taxonomy":"audience","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/audience?post=5086"},{"taxonomy":"content-type","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/content-type?post=5086"},{"taxonomy":"product","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/product?post=5086"},{"taxonomy":"tech-community","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/tech-community?post=5086"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/topic?post=5086"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/azure.microsoft.com\/en-us\/blog\/wp-json\/wp\/v2\/coauthors?post=5086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}