Skip to content

Commit a54a94a

Browse files
committed
edits
1 parent 6b0d695 commit a54a94a

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed
-84.1 KB
Loading
-52.4 KB
Loading

articles/service-fabric/service-fabric-tutorial-dotnet-app-enable-https-endpoint.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ $nsg | Set-AzNetworkSecurityGroup
430430

431431
## Deploy the application to Azure
432432

433-
Save all files, switch from Debug to Release, and select F6 to rebuild. In Solution Explorer, right-click **Voting** and select **Publish**. Select the connection endpoint of the cluster created in [Deploy an application to a cluster](service-fabric-tutorial-deploy-app-to-party-cluster.md), or select another cluster. Select **Publish** to publish the application to the remote cluster.
433+
Save all files, switch from Debug to Release, and select F6 to rebuild. In Solution Explorer, right-click **Voting** and select **Publish**. Select the connection endpoint of the cluster created in [Deploy an application to a cluster](service-fabric-tutorial-deploy-app.md), or select another cluster. Select **Publish** to publish the application to the remote cluster.
434434

435435
When the application deploys, open a web browser and go to `https://mycluster.region.cloudapp.azure.com:443` (update the URL with the connection endpoint for your cluster). If you're using a self-signed certificate, you see a warning that your PC doesn't trust this website's security. Continue to the webpage.
436436

articles/service-fabric/service-fabric-tutorial-monitoring-aspnet.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.date: 05/17/2024
1111

1212
# Tutorial: Monitor and diagnose an ASP.NET Core application on Service Fabric by using Application Insights
1313

14-
This tutorial is *part five* in a series. It walks through the steps to configure monitoring and diagnostics for an ASP.NET Core application running on an Azure Service Fabric cluster by using Application Insights. You collect telemetry from the application that's developed in [part one of the tutorial](service-fabric-tutorial-create-dotnet-app.md).
14+
This tutorial is *part five* in a series. It walks through the steps to configure monitoring and diagnostics for an ASP.NET Core application running on an Azure Service Fabric cluster by using Application Insights. You collect telemetry from the application that's developed in [part one of the tutorial series](service-fabric-tutorial-create-dotnet-app.md).
1515

1616
In this tutorial, you learn how to:
1717

@@ -25,10 +25,10 @@ In this tutorial, you learn how to:
2525
The tutorial series shows you how to:
2626

2727
* [Build a .NET Service Fabric application](service-fabric-tutorial-create-dotnet-app.md)
28-
* [Deploy the application to a remote cluster](service-fabric-tutorial-deploy-app-to-party-cluster.md)
28+
* [Deploy the application to a remote cluster](service-fabric-tutorial-deploy-app.md)
2929
* [Add an HTTPS endpoint to an ASP.NET Core front-end service](service-fabric-tutorial-dotnet-app-enable-https-endpoint.md)
3030
* [Configure CI/CD by using Azure Pipelines](service-fabric-tutorial-deploy-app-with-cicd-vsts.md)
31-
* Set up monitoring and diagnostics for the application
31+
* Set up monitoring and diagnostics for the application (*this tutorial*)
3232

3333
## Prerequisites
3434

@@ -50,11 +50,11 @@ git clone https://github.com/Azure-Samples/service-fabric-dotnet-quickstart
5050

5151
Application Insights is the Azure application performance management platform. We recommend that you use Application Insights for application monitoring and diagnostics in Service Fabric.
5252

53-
To create an Application Insights resource, go to the [Azure portal](https://portal.azure.com). Select **+ Create a resource**. On the portal menu, select **Monitoring + Diagnostics**. In the **Popular Azure services** column, under **Application Insights**, select **Create**.
53+
To create an Application Insights resource, go to the [Azure portal](https://portal.azure.com). Select **Create a resource**. On the portal menu, select **Monitoring + Diagnostics**. In the **Popular Azure services** column, under **Application Insights**, select **Create**.
5454

5555
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/new-ai-resource.png" alt-text="Screenshot that shows you how to create a new Application Insights resource.":::
5656

57-
Enter or select values for **Subscription**, **Resource group**, and **Name**. For **Region**, choose where you will deploy your Service Fabric cluster in the future. In this tutorial, we deploy the app to a local cluster, so the Azure region is irrelevant. For **Application type**, leave as **ASP.NET web application**.
57+
Enter or select values for **Subscription**, **Resource group**, and **Name**. For **Region**, choose where to deploy your Service Fabric cluster in the future. In this tutorial, we deploy the app to a local cluster, so the Azure region is irrelevant. For **Application type**, leave as **ASP.NET web application**.
5858

5959
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/new-ai-resource-attrib.png" alt-text="Screenshot that shows Application Insights resource attributes.":::
6060

@@ -70,25 +70,25 @@ To configure Application Insights for the VotingWeb and VotingData services:
7070

7171
1. Right-click the name of the service, and select **Add** > **Connected Services** > **Monitoring with Application Insights**.
7272

73-
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/configure-ai.png" alt-text="Screenshot that shows configuring Application Insights services.":::
73+
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/configure-ai.png" alt-text="Screenshot that shows configuring Application Insights services.":::
7474

75-
> [!NOTE]
75+
> [!NOTE]
7676
> Depending on the project type, when you right-click the name of the service, you might need to select **Add** and then select **Application Insights Telemetry**.
7777
7878
1. Select **Get started**.
79-
1. Sign in to the account that you use for your Azure subscription and select the subscription where you created the Application Insights resource. To find the resource, under the **Resource** dropdown, go to **Existing Application Insights resource**. Select **Register** to add Application Insights to your service.
79+
1. Sign in to the account that you use for your Azure subscription and select the subscription where you created the Application Insights resource. To find the resource, in **Resource**, go to **Existing Application Insights resource**. Select **Register** to add Application Insights to your service.
8080

8181
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/register-ai.png" alt-text="Screenshot that shows how to register Application Insights.":::
8282

83-
1. When the dialog that completes the action pops up, select **Finish**.
83+
1. Select **Finish**.
8484

8585
> [!NOTE]
8686
> Make sure to do these steps for *both* of the services in the application to finish configuring Application Insights for the application.
8787
> The same Application Insights resource is used for both of the services in order to see incoming and outgoing requests and communication between the services.
8888
8989
## Add the Microsoft.ApplicationInsights.ServiceFabric.Native NuGet to the services
9090

91-
Application Insights has two Service Fabric-specific NuGet packages that you can use depending on the scenario. One is used with Service Fabric native services, and the other with containers and guest executables. In this case, we're using the Microsoft.ApplicationInsights.ServiceFabric.Native NuGet package to use the understanding of service context that it brings. To read more about the Application Insights SDK and the Service Fabric-specific NuGet packages, see [Microsoft Application Insights for Service Fabric](https://github.com/Microsoft/ApplicationInsights-ServiceFabric/blob/master/README.md).
91+
Application Insights has two Service Fabric-specific NuGet packages that you can use depending on the scenario. One is used with Service Fabric native services, and the other with containers and guest executables. In this case, we use the Microsoft.ApplicationInsights.ServiceFabric.Native NuGet package to learn about service context. For more information about the Application Insights SDK and the Service Fabric-specific NuGet packages, see [Microsoft Application Insights for Service Fabric](https://github.com/Microsoft/ApplicationInsights-ServiceFabric/blob/master/README.md).
9292

9393
To set up the NuGet package:
9494

@@ -98,27 +98,27 @@ To set up the NuGet package:
9898
> [!NOTE]
9999
> You might need to install the Microsoft.ServiceFabric.Diagnostics.Internal package in the same way if it wasn't preinstalled before you installed the Application Insights package.
100100
101-
1. Search for **Microsoft.ApplicationInsights.ServiceFabric.Native**, and then select the appropriate NuGet package.
102-
1. In the right pane, select the **VotingWeb** checkbox and the **VotingData** checkbox. Select **Install**.
101+
1. Search for **Microsoft.ApplicationInsights.ServiceFabric.Native**, and then select the NuGet package.
102+
1. On the right pane, select the **VotingWeb** checkbox and the **VotingData** checkbox. Select **Install**.
103103

104104
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/ai-sdk-nuget-new.png" alt-text="Screenshot that shows the Application Insights SDK in NuGet.":::
105105
1. In the **Preview Changes** dialog, select **OK** to accept the license. The NuGet packages are added to the services.
106106
1. Next, set up the telemetry initializer in the two services. Open *VotingWeb.cs* and *VotingData.cs*. Complete the following steps in both code files:
107107

108108
1. Add these two `using` statements at the top of each file, after the existing `using` statements:
109109

110-
```csharp
111-
using Microsoft.ApplicationInsights.Extensibility;
112-
using Microsoft.ApplicationInsights.ServiceFabric;
113-
```
110+
```csharp
111+
using Microsoft.ApplicationInsights.Extensibility;
112+
using Microsoft.ApplicationInsights.ServiceFabric;
113+
```
114114

115115
1. In both files, in the nested `return` statement of `CreateServiceInstanceListeners()` or `CreateServiceReplicaListeners()`, under `ConfigureServices` > `services`, with the other singleton services declared, add:
116116

117117
```csharp
118118
.AddSingleton<ITelemetryInitializer>((serviceProvider) => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(serviceContext))
119119
```
120120

121-
This code adds `Service Context` to your telemetry, so you can better understand the source of your telemetry in Application Insights. Your nested *return* statement in *VotingWeb.cs* now looks similar to this example:
121+
This code adds `Service Context` to your telemetry, so you can better understand the source of your telemetry in Application Insights. Your nested `return` statement in *VotingWeb.cs* now looks similar to this example:
122122

123123
```csharp
124124
return new WebHostBuilder()
@@ -139,26 +139,26 @@ To set up the NuGet package:
139139

140140
In *VotingData.cs*, your code now looks similar to this example:
141141

142-
```csharp
143-
return new WebHostBuilder()
144-
.UseKestrel()
145-
.ConfigureServices(
146-
services => services
147-
.AddSingleton<StatefulServiceContext>(serviceContext)
148-
.AddSingleton<IReliableStateManager>(this.StateManager)
149-
.AddSingleton<ITelemetryInitializer>((serviceProvider) => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(serviceContext)))
150-
.UseContentRoot(Directory.GetCurrentDirectory())
151-
.UseStartup<Startup>()
152-
.UseApplicationInsights()
153-
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
154-
.UseUrls(url)
155-
.Build();
156-
```
142+
```csharp
143+
return new WebHostBuilder()
144+
.UseKestrel()
145+
.ConfigureServices(
146+
services => services
147+
.AddSingleton<StatefulServiceContext>(serviceContext)
148+
.AddSingleton<IReliableStateManager>(this.StateManager)
149+
.AddSingleton<ITelemetryInitializer>((serviceProvider) => FabricTelemetryInitializerExtension.CreateFabricTelemetryInitializer(serviceContext)))
150+
.UseContentRoot(Directory.GetCurrentDirectory())
151+
.UseStartup<Startup>()
152+
.UseApplicationInsights()
153+
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
154+
.UseUrls(url)
155+
.Build();
156+
```
157157

158158
Double-check that the `UseApplicationInsights()` method is called in both *VotingWeb.cs* and *VotingData.cs* as shown in the examples.
159159

160160
> [!NOTE]
161-
> This sample app uses HTTP for the services to communicate. If you develop an app by using Service Remoting V2, you also add the following lines in the same location in the code:
161+
> This sample app uses HTTP for the services to communicate. If you develop an app by using Service Fabric Service Remoting V2, also add the following lines in the same location in the code:
162162

163163
```csharp
164164
ConfigureServices(services => services
@@ -168,12 +168,12 @@ ConfigureServices(services => services
168168
)
169169
```
170170

171-
At this point, you're ready to deploy the application. Select **Start** at the top (or select F5). Visual Studio builds and packages the application, sets up your local cluster, and deploys the application to the cluster.
171+
At this point, you're ready to deploy the application. Select **Start** (or select F5). Visual Studio builds and packages the application, sets up your local cluster, and deploys the application to the cluster.
172172

173173
> [!NOTE]
174174
> You might get a build error if you don't have an up-to-date version of the .NET Core SDK installed.
175175
176-
When the application is deployed, go to `localhost:8080`, where you should be able to see the Voting Sample single-page application. Vote for a few different items of your choice to create some sample data and telemetry. For example, desserts!
176+
When the application is deployed, go to `localhost:8080`, where the Voting Sample single-page application is running. Vote for a few different items of your choice to create some sample data and telemetry. For example, desserts!
177177

178178
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/vote-sample.png" alt-text="Screenshot that shows an example of voting for types of dessert.":::
179179

@@ -203,9 +203,9 @@ Application Map can help you understand your application topology better, especi
203203

204204
## Add custom instrumentation to your application
205205

206-
Although Application Insights provides telemetry out of the box, you might want to add more custom instrumentation. Maybe you might have business needs for custom instrumentation or you want to improve diagnostics when things go wrong in your application. You can ingest custom events and metrics with the [Application Insights API](../azure-monitor/app/api-custom-events-metrics.md).
206+
Although Application Insights provides telemetry out of the box, you might want to add custom instrumentation. Maybe you have business needs for custom instrumentation or you want to improve diagnostics when things go wrong in your application. You can ingest custom events and metrics by using the [Application Insights API](../azure-monitor/app/api-custom-events-metrics.md).
207207

208-
Next, add some custom events to *VoteDataController.cs* (under **VotingData** > **Controllers**) to track when votes are being added and deleted from the underlying *votesDictionary*:
208+
Next, add some custom events to *VoteDataController.cs* (in `VotingData` > `Controllers`) to track when votes are being added and deleted from the underlying `votesDictionary`:
209209

210210
1. Add `using Microsoft.ApplicationInsights;` at the end of the other `using` statements.
211211
1. Declare a new value for `TelemetryClient` at the start of the class, under the creation of `IReliableStateManager`: `private TelemetryClient telemetry = new TelemetryClient();`.
@@ -260,7 +260,7 @@ public async Task<IActionResult> Delete(string name)
260260
}
261261
```
262262

263-
When you finish making these changes, select **Start** in the application so that it builds and deploys the latest version. When the application is finished deploying, go to `localhost:8080`, and add and delete some voting options. Then, go back to your Application Insights resource to see the traces for the latest run (as before, traces can take from 1 to 2 minutes to appear in Application Insights). For all the votes that you added and deleted, you should now see an entry for **Custom Event** with all the response telemetry.
263+
When you finish making these changes, select **Start** in the application so that it builds and deploys the latest version. When the application is finished deploying, go to `localhost:8080`. Add and delete some voting options. Then, go back to your Application Insights resource to see the traces for the latest run (traces take from 1 to 2 minutes to appear in Application Insights). For all the votes that you added and deleted, you should now see an entry for **Custom Event** with associated response telemetry.
264264

265265
:::image type="content" source="media/service-fabric-tutorial-monitoring-aspnet/custom-events.png" alt-text="Screenshot that shows custom events.":::
266266

0 commit comments

Comments
 (0)