Book Image

Advanced Serverless Architectures with Microsoft Azure

By : Daniel Bass
Book Image

Advanced Serverless Architectures with Microsoft Azure

By: Daniel Bass

Overview of this book

Advanced Serverless Architectures with Microsoft Azure redefines your experience of designing serverless systems. It shows you how to tackle challenges of varying levels, not just the straightforward ones. You'll be learning how to deliver features quickly by building systems, which retain the scalability and benefits of serverless. You'll begin your journey by learning how to build a simple, completely serverless application. Then, you'll build a highly scalable solution using a queue, load messages onto the queue, and read them asynchronously. To boost your knowledge further, the book also features durable functions and ways to use them to solve errors in a complex system. You'll then learn about security by building a security solution from serverless components. Next, you’ll gain an understanding of observability and ways to leverage application insights to bring you performance benefits. As you approach the concluding chapters, you’ll explore chaos engineering and the benefits of resilience, by actively switching off a few of the functions within a complex system, submitting a request, and observing the resulting behavior. By the end of this book, you will have developed the skills you need to build and maintain increasingly complex systems that match evolving platform requirements.
Table of Contents (8 chapters)

Chapter 5: Observability


Activity 5: Identifying an Issue with Your Serverless Architecture

  1. 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:

    Figure 5.17: Modify the connection string

  2. 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:

    Figure 5.18: Application Insights showing the database is unavailable

  3. 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:

    Figure 5.19: Erroneous code

  4. 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:

    Figure 5.20: Repaired code

Activity 6: Diagnosing an Issue with an Azure Durable Function

  1. 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:

    Figure 5.21: Application Settings for the Durable Function

  2. 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.

  3. Go to your order.html file in the Azure Storage account and submit an order:

    Figure 5.22: order.html page

  4. 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.

    Figure 5.23: Application Map

  5. Navigate to the overview page and click on the Analytics section, as before. Look for exceptions:

    Figure 5.24: Error with Durable Function

  6. 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:

    Figure 5.25: Error with Durable Function

  7. 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:

    Figure 5.26: Code problem with PackAndShipOrder.cs