AZ-204 Exam Preparation - Additional Topics

Contents

AZ-204 Exam Preparation
1
Additional Topics
PREVIEW6m 41s

The course is part of this learning path

Additional Topics
Difficulty
Intermediate
Duration
7m
Students
1440
Ratings
4.8/5
starstarstarstarstar-half
Description

This course explains some additional topics you should make sure you understand before taking the AZ-204 exam, including:

  • Azure Container Instances
  • Durable Functions
  • Implementing web tests with Application Insights
Transcript

Congratulations on making it all the way through this learning path. There are a few topics that you’ll need to know for the exam that weren’t covered yet, so I’ll go over them now.

First up is Azure Container Instances. Although Kubernetes is usually the preferred system for running container-based applications, it would be overkill if you just need to run one container. For example, suppose you want to deploy a simple web application that’s in a single Docker container. Using Azure Container Instances, you can deploy it very easily.

All you have to do is run the az container create command and specify the resource group, the name you want to give the container, the image it should use to build the container, the DNS name to assign to its public IP address, and the ports you want to open. This single command will spin up your container. I should point out that the name parameter is technically for the name of the container group because it’s possible to spin up more than one container at the same time, but in most cases, you’ll probably use this command to spin up only a single container.

If you want to check the status of your container, you can use the az container show command. This will give you lots of details about your container, such as its IP address, its operating system, and its current state.

It’s also possible to create and manage Azure Container Instances using PowerShell or the Azure Portal.

The next topic is a feature of Azure Functions called Durable Functions. Typically Azure functions are stateless, meaning when a function runs, it doesn’t know anything about previous runs of that function. A classic example of an Azure function is one that waits for an image file to be uploaded to a particular container in Blob storage and then creates a thumbnail version of that image. It’s stateless because it doesn’t matter what images it processed in the past, it runs in exactly the same way every time. Furthermore, it doesn’t care what other Azure functions are doing either. It only cares about its own job.

This approach is fine for simple applications, but if you try to build a more complex application out of stateless functions, you’ll probably have to write a lot of code to try to coordinate the actions of these functions.

For example, suppose you’re writing an order processing system that needs to execute four different functions in the same sequence every time. To make that happen, you’d have to write code to ensure that the output of the first function triggers the execution of the second function, and so on. It is possible to do this by creating events, but it’s much easier to use the Durable Functions library. Here’s what the C# code for this would look like.

[FunctionName("ProcessOrder")]
public static async Task < object > Run([OrchestrationTrigger] IDurableOrchestrationContext context) {
	try {
		var x = await context.CallActivityAsync < object > ("Function1", null);
		var y = await context.CallActivityAsync < object > ("Function2", x);
		var z = await context.CallActivityAsync < object > ("Function3", y);
		return await context.CallActivityAsync < object > ("Function4", z);
	}
	catch(Exception) {
		// Error handling or compensation goes here.
	}
}

Here are the four functions. You just need to put them in the order you want. Also notice the error handing section down here. This is another reason why it’s way easier to orchestrate a workflow using Durable Functions than to try to do it yourself. Here, your error handling code can deal with multiple components in the workflow, which would be very difficult to do with stateless functions.

This is actually one of the simplest use cases for Durable Functions. A more complicated example is called fan-out / fan-in. The first function splits the work into multiple tasks that will be executed in parallel by the second function. Then the output from these parallel tasks needs to be aggregated and sent to the third function. This is much more challenging than the previous example because the third function needs to know when all of the parallel functions have completed. Using the Durable Functions extension, the code for this is still relatively straightforward.

The next topic is how to implement web tests using Application Insights. Once you’ve deployed a web application, you’ll want to monitor its availability so you’ll know if it ever goes down. Application Insights provides a great tool to do that.

Go to Application Insights, and then select Availability from the menu. Now click Add Test. The only parameters you have to set are the name of the test and the URL of the website. But there are lots of options.

The default test type is a URL ping test, but you can configure a multi-step web test if you want. This is a recording of a series of requests to send to your website. To create it, you have to use Visual Studio Enterprise.

Parse dependent requests means request all of the images, scripts, and other files in the web page instead of just the one file at the URL you specified.

When this is checked, the test won’t fail until it has tried to connect three times with a 20-second delay between retries. You can also change how often the test is run.

Here, you can set which locations to test from. Microsoft recommends testing from at least five locations.

When you’ve set all of the options, click the Create button. Here’s the web test.

There’s one more step that’s really important. You need to tell it where to send alerts when there’s a problem with the website. But it’s not obvious where to do that. In the context menu for the web test, select Edit alert. Under Action Groups, click Create. Give the action group a name. Then you have to give it a short name that’s a maximum of 12 characters.

You can put it in an existing resource group or just leave it so it’ll create this default resource group. Give the action a name. Under Action type, select Email/SMS/Push/Voice (or one of the other options if you want to send the alerts somewhere else). I’ll tell it to send an email to this address. Click OK, and click OK again. Now click Save.

It’s also possible to set up a web test using an ARM template. Here’s a link to an example of how to do that. OK, that’s it for additional topics for the AZ-204 exam. Please give this course a rating, and if you have any questions or comments, please let us know. Thanks and good luck on the exam!

About the Author
Students
190944
Courses
98
Learning Paths
169

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).