Deploy the ProductsApi function app provided in the Activity 5 folder and modify the connection string in the index.html file to connect to the ProductsApi function app. Ensure that it has the Application Insights identifier on it, as shown here:
Open the Application Insights instance and navigate to the search tab. There will be a Severity level: Error log saying that the database is unavailable:
Open the GetProducst.cs file in the ProductsApi folder supplied in the Activity 5 folder. There is a section of code that throws an exception at random:
Remove this piece of code that is throwing the errors and deploy it. You will now no longer get issues logged to App Insights. Your repaired code should look as follows:
Add APPINSIGHTS_INSTRUMENTATIONKEY to your Durable Function's function app's local.settings.json file if running locally, or to the Application settings page if running in the cloud from Chapter 3, Azure Durable Functions. Create and deploy a new one from Visual Studio Code if needed:
Add the APPINSIGHTS_INSTRUMENTATIONKEY to your OrdersApi function app from Chapter 3, Azure Durable Functions. Create and deploy a new one from Visual Studio Code if needed.
Go to your order.html file in the Azure Storage account and submit an order:
Open the Application Insights instance and click on Application map. This is a really interesting view that lays out the components of your application and shows their dependencies on one another and other components. You can see some dependency issues in the screenshot, which are highlighted in red with a percentage of failed calls. This would usually be the first thing you would investigate, as it's very likely to be the cause of the issues.
Navigate to the overview page and click on the Analytics section, as before. Look for exceptions:
Identify the series of System.InvalidOperationException errors. Open the first one. You will see that there is a problem with retrieving the SendGrid API Key:
The API key is present on the function app, so the reference in the code must be the error. Open the PackAndShipOrder.cs file in Visual Studio Code and observe that the SendGrid API Key name does not match the app setting name—the app setting name is called SendGridApiKey and the function is looking for an app setting called SendGridApiKey2: