You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/app/availability-azure-functions.md
+45-34Lines changed: 45 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,47 +1,58 @@
1
1
---
2
-
title: Create and run custom availability tests using Azure Functions
3
-
description: This doc will cover how to create an Azure Function with TrackAvailability() that will run periodically according to the configuration given in TimerTrigger function. The results of this test will be sent to your Application Insights resource, where you will be able to query for and alert on the availability results data. Customized tests will allow you to write more complex availability tests than is possible using the portal UI, monitor an app inside of your Azure VNET, change the endpoint address, or create an availability test if it's not available in your region.
2
+
title: Create and run custom availability tests by using Azure Functions
3
+
description: This article explains how to create an Azure function with TrackAvailability() that will run periodically according to the configuration given in a TimerTrigger function.
4
4
ms.topic: conceptual
5
5
ms.date: 05/06/2021
6
6
ms.devlang: csharp
7
7
---
8
8
9
-
# Create and run custom availability tests using Azure Functions
9
+
# Create and run custom availability tests by using Azure Functions
10
10
11
-
This article will cover how to create an Azure Function with TrackAvailability() that will run periodically according to the configuration given in TimerTrigger function with your own business logic. The results of this test will be sent to your Application Insights resource, where you will be able to query for and alert on the availability results data. This allows you to create customized tests similar to what you can do via [Availability Monitoring](./monitor-web-app-availability.md) in the portal. Customized tests will allow you to write more complex availability tests than is possible using the portal UI, monitor an app inside of your Azure VNET, change the endpoint address, or create an availability test even if this feature is not available in your region.
11
+
This article explains how to create an Azure function with `TrackAvailability()` that will run periodically according to the configuration given in the `TimerTrigger` function with your own business logic. The results of this test will be sent to your Application Insights resource, where you can query for and alert on the availability results data. Then you can create customized tests similar to what you can do via [availability monitoring](./monitor-web-app-availability.md) in the Azure portal. By using customized tests, you can:
12
+
13
+
- Write more complex availability tests than is possible by using the portal UI.
14
+
- Monitor an app inside of your Azure virtual network.
15
+
- Change the endpoint address.
16
+
- Create an availability test even if this feature isn't available in your region.
12
17
13
18
> [!NOTE]
14
-
> This example is designed solely to show you the mechanics of how the TrackAvailability() API call works within an Azure Function. Not how to write the underlying HTTP Test code/business logic that would be required to turn this into a fully functional availability test. By default if you walk through this example you will be creating a basic availability HTTP GET test.
19
+
> This example is designed solely to show you the mechanics of how the `TrackAvailability()` API call works within an Azure function. It doesn't show you how to write the underlying HTTP test code or business logic that's required to turn this example into a fully functional availability test. By default, if you walk through this example, you'll be creating a basic availability HTTP GET test.
20
+
>
15
21
> To follow these instructions, you must use the [dedicated plan](../../azure-functions/dedicated-plan.md) to allow editing code in App Service Editor.
16
22
17
23
## Create a timer trigger function
18
24
19
25
1. Create an Azure Functions resource.
20
-
- If you already have an Application Insights Resource:
21
-
- By default Azure Functions creates an Application Insights resource but if you would like to use one of your already created resources you will need to specify that during creation.
26
+
- If you already have an Application Insights resource:
27
+
28
+
- By default, Azure Functions creates an Application Insights resource. But if you want to use a resource you created previously, you must specify that during creation.
22
29
- Follow the instructions on how to [create an Azure Functions resource](../../azure-functions/functions-create-scheduled-function.md#create-a-function-app) with the following modification:
23
-
- On the **Monitoring** tab, select the Application Insights dropdown box then type or select the name of your resource.
24
-
:::image type="content" source="media/availability-azure-functions/app-insights-resource.png" alt-text="On the monitoring tab select your existing Application Insights resource.":::
25
-
- If you do not have an Application Insights Resource created yet for your timer triggered function:
26
-
- By default when you are creating your Azure Functions application it will create an Application Insights resource for you. Follow the instructions on how to [create an Azure Functions resource](../../azure-functions/functions-create-scheduled-function.md#create-a-function-app).
30
+
31
+
On the **Monitoring** tab, select the **Application Insights** dropdown box and then enter or select the name of your resource.
32
+
33
+
:::image type="content" source="media/availability-azure-functions/app-insights-resource.png" alt-text="Screenshot that shows selecting your existing Application Insights resource on the Monitoring tab.":::
34
+
35
+
- If you don't have an Application Insights resource created yet for your timer-triggered function:
36
+
- By default, when you're creating your Azure Functions application, it will create an Application Insights resource for you. Follow the instructions on how to [create an Azure Functions resource](../../azure-functions/functions-create-scheduled-function.md#create-a-function-app).
37
+
27
38
> [!NOTE]
28
-
> You can host your functions on a Consumption, Premium, or App Service plan. If you are testing behind a V-Net or testing non public endpoints then you will need to use the premium plan in place of the consumption. Select your plan on the **Hosting** tab. Please ensure the latest .NET version is selected when creating the Function App.
29
-
2. Create a timer trigger function.
39
+
> You can host your functions on a Consumption, Premium, or App Service plan. If you're testing behind a virtual network or testing nonpublic endpoints, you'll need to use the Premium plan in place of the Consumption plan. Select your plan on the **Hosting** tab. Ensure the latest .NET version is selected when you create the function app.
40
+
1. Create a timer trigger function.
30
41
1. In your function app, select the **Functions** tab.
31
-
1. Select **Add** and in the Add function tab select the follow configurations:
32
-
1. Development environment: *Develop in portal*
33
-
1. Select a template: *Timer trigger*
34
-
1. Select **Add** to create the Timer trigger function.
42
+
1. Select **Add**. On the **Add function** pane, select the following configurations:
43
+
1.**Development environment**: **Develop in portal**
44
+
1.**Select a template**: **Timer trigger**
45
+
1. Select **Add** to create the timer trigger function.
35
46
36
-
:::image type="content" source="media/availability-azure-functions/add-function.png" alt-text="Screenshot of how to add a timer trigger function to your function app." lightbox="media/availability-azure-functions/add-function.png":::
47
+
:::image type="content" source="media/availability-azure-functions/add-function.png" alt-text="Screenshot that shows how to add a timer trigger function to your function app." lightbox="media/availability-azure-functions/add-function.png":::
37
48
38
49
## Add and edit code in the App Service Editor
39
50
40
-
Navigate to your deployed function app and under *Development Tools* select the **App Service Editor** tab.
51
+
Go to your deployed function app, and under **Development Tools**, select the **App Service Editor** tab.
41
52
42
-
To create a new file, rightclick under your timer trigger function (for example "TimerTrigger1") and select **New File**. Then type the name of the file and press enter.
53
+
To create a new file, right-click under your timer trigger function (for example, **TimerTrigger1**) and select **New File**. Then enter the name of the file and select **Enter**.
43
54
44
-
1. Create a new file called "function.proj" and paste the following code:
55
+
1. Create a new file called **function.proj** and paste the following code:
45
56
46
57
```xml
47
58
<ProjectSdk="Microsoft.NET.Sdk">
@@ -54,9 +65,9 @@ To create a new file, right click under your timer trigger function (for example
54
65
</Project>
55
66
```
56
67
57
-
:::image type="content" source="media/availability-azure-functions/function-proj.png" alt-text=" Screenshot of function.proj in App Service Editor." lightbox="media/availability-azure-functions/function-proj.png":::
68
+
:::image type="content" source="media/availability-azure-functions/function-proj.png" alt-text=" Screenshot that shows function.proj in the App Service Editor." lightbox="media/availability-azure-functions/function-proj.png":::
58
69
59
-
2. Create a new file called "runAvailabilityTest.csx" and paste the following code:
70
+
1. Create a new file called **runAvailabilityTest.csx** and paste the following code:
60
71
61
72
```csharp
62
73
using System.Net.Http;
@@ -71,7 +82,7 @@ To create a new file, right click under your timer trigger function (for example
71
82
}
72
83
```
73
84
74
-
3. Copy the code below into the run.csx file (this will replace the pre-existing code):
85
+
1. Copy the following code into the **run.csx** file. (You'll replace the preexisting code.)
75
86
76
87
```csharp
77
88
#load "runAvailabilityTest.csx"
@@ -161,26 +172,26 @@ To create a new file, right click under your timer trigger function (for example
161
172
162
173
## Check availability
163
174
164
-
To make sure everything is working, you can look at the graph in the Availability tab of your Application Insights resource.
175
+
To make sure everything is working, look at the graph on the **Availability** tab of your Application Insights resource.
165
176
166
177
> [!NOTE]
167
-
> Tests created with TrackAvailability() will appear with **CUSTOM** next to the test name.
178
+
> Tests created with `TrackAvailability()` will appear with **CUSTOM** next to the test name.
168
179
169
-
:::image type="content" source="media/availability-azure-functions/availability-custom.png" alt-text="Availability tab with successful results." lightbox="media/availability-azure-functions/availability-custom.png":::
180
+
:::image type="content" source="media/availability-azure-functions/availability-custom.png" alt-text="Screenshot that shows the Availability tab with successful results." lightbox="media/availability-azure-functions/availability-custom.png":::
170
181
171
-
To see the end-to-end transaction details, select **Successful** or **Failed** under drill into, then select a sample. You can also get to the end-to-end transaction details by selecting a data point on the graph.
182
+
To see the end-to-end transaction details, under **Drill into**, select **Successful** or **Failed**. Then select a sample. You can also get to the end-to-end transaction details by selecting a data point on the graph.
172
183
173
-
:::image type="content" source="media/availability-azure-functions/sample.png" alt-text="Select a sample availability test.":::
184
+
:::image type="content" source="media/availability-azure-functions/sample.png" alt-text="Screenshot that shows selecting a sample availability test.":::
:::image type="content" source="media/availability-azure-functions/end-to-end.png" alt-text="Screenshot that shows end-to-end transaction details." lightbox="media/availability-azure-functions/end-to-end.png":::
176
187
177
-
## Query in Logs (Analytics)
188
+
## Query in Log Analytics
178
189
179
-
You can use Logs(analytics) to view you availability results, dependencies, and more. To learn more about Logs, visit [Log query overview](../logs/log-query-overview.md).
190
+
You can use Log Analytics to view your availability results, dependencies, and more. To learn more about Log Analytics, see [Log query overview](../logs/log-query-overview.md).
:::image type="content" source="media/availability-azure-functions/availabilityresults.png" alt-text="Screenshot that shows availability results." lightbox="media/availability-azure-functions/availabilityresults.png":::
182
193
183
-
:::image type="content" source="media/availability-azure-functions/dependencies.png" alt-text="Screenshot shows New Query tab with dependencies limited to 50." lightbox="media/availability-azure-functions/dependencies.png":::
194
+
:::image type="content" source="media/availability-azure-functions/dependencies.png" alt-text="Screenshot that shows the New Query tab with dependencies limited to 50." lightbox="media/availability-azure-functions/dependencies.png":::
0 commit comments