Practice Exams:

AZ-204 Microsoft Azure Developer Associate – Connect to and consume Azure and third-party services part 1

  1. AZ-203/ 204 – Lab – Azure Logic Apps

Hi and welcome back. Now in this lab, let’s look at Azure logic apps. So before we go into our lab, let’s look at Azure logic apps. So this is a cloud service that helps you schedule, automate and orchestrate tasks, business processes, and workflows. So how does it work? Well, firstly, design a workflow in Azure logic apps, each workflow starts with something known as a trigger. So the trigger basically triggers the workflow. The trigger is fired via a specific event. It depends on the type of trigger that you create for the workflow. When the trigger is fired, the logic app engine creates a logic app instance that then runs the workflow. You also have connectors for Azure logic apps. So these are connectors that provide easy access onto event data and actions that are sent from external application services, systems or platforms.

So for example, let’s say you want to connect Azure logic apps onto another Azure service such as Azure Storage. You could use the built in connectors. So you have built in connectors that can actually connect onto Azure services. You also have managed connectors that can connect to platforms such as Office 365, Microsoft Dynamics. So what are we going to see in our lab so that we get a better understanding on Azure logic apps? Well, first we’re going to create a new logic app. That logic app will be triggered whenever a Blob object is added to a container in a storage account. And then finally, the logic app will send a message of the file name to an email address. So let’s go ahead and see how we can implement logic apps. So here we are.

Zero. So first things first, let’s go ahead and add a resource. We can search for logic app. Let’s go ahead and create it. We’ll give a name for the logic app, choose a resource group, go ahead and create the logic app. Now, once the resource is in place, let’s go ahead onto the logic app. So the first thing you are presented with is the logic app designer. So there are common triggers that are available, there are common templates that are available that help you kickstart the workflow in Azure logic apps. So you can see there are so many triggers that are available. So you could have a trigger that whenever a message is received in a service bus queue, then go ahead and trigger a workflow. Or you could have an external service such as Twitter.

So whenever a new tweet is posted, you can go ahead and trigger a workflow. So there are triggers that not only connect onto Azure services, can also connect on to different other platforms as well. You also have templates. So in this templates, you already have a string of actions and triggers in the workflow itself. For now, let’s go ahead and create a blank logic app so that we get a better understanding. So first thing we can do is we can search for connectors and triggers. So what should trigger this workflow? So in our example, we are going to trigger this workflow whenever an object is added onto a container in a storage account. So in another tab, I have a storage account in placed on this app store. Let me go on to the blob service and let me add a container.

I’ll give a simple name for the container. Click on okay. So whenever I upload an object onto this container, it should go ahead and trigger this workflow. So let’s go ahead and search for storage. So here it’s gone ahead and found all of the triggers which are available with the term of storage. We then have triggers and actions. So let me go on to the triggers. So here is a trigger which I want. So whenever a blob is added or modified onto Azure Blob Storage, that’s the trigger that I want to add onto the workflow. So let me choose that. Now this workflow needs to connect to a storage account. So it needs to create a connection. So let’s give it a name. Let’s choose the storage account. Click on Create, right? So now it’s gone ahead and created the connection.

Let me go ahead and choose the container. So I’ll choose the demo container. So the number of blobs to return from the trigger. So here, giving a limit on the number of blobs that can be returned from the trigger, how often do you want to check for the items? So since this is just a demo, I’ll reduce the frequency, right? So now we have our trigger in place. So I want to add now a new step, a new action. What happens when our workflow is triggered? So let me go ahead and click on New Step. So here you can see there are a whole lot of actions that are available for you. Now what I want to do is that I want to go ahead and actually send an email message. So let me go ahead and search for Gmail. So it even has an integration with external services.

So over here I want to say that go ahead and send an email. Let me sign into my Gmail account so it will pop up a new window. That window will ask you to authorize Azure logic apps onto the email service. So let me go ahead and do that. So once I’ve authenticated myself, I vented my username and password onto my Gmail account. I can go ahead and click on Allow. So I’m basically giving access to the logic app service onto my Gmail account. So in the send email, who do I want to send an email to? I’ll just write my own email address. Let me go ahead and add a parameter of the body and a subject. So in the subject I just write details and in the body you can actually add dynamic content. So I want to say that I want to have the list of file names or file display name.

Now let me go ahead and click on save. So now I basically have a workflow in place. So I have my trigger and then I have an action. So let me go on to the container, let me upload a file. So I’m uploading a simple audio log file. Let me click on upload and if I go on to my email address, you can now see that I’ve received an email with the name of the file. So there is a lot of things you can actually do. We can build an entire workflow UFI Set connectors. They have triggers that not only connect onto Azure services, but on to other external services as well. If you look at the code view so this is the designer view for the workflow workflow. If you look at the core view so here you have the JSON bit definition for the logic app itself. Right? So this marks the end of this lab.

  1. AZ-203/ 204 – Lab – Azure Logic Apps use case

Hi and welcome back. Now in this lab, we’re going to look at one of the templates that’s available with Azure Logic App. And that template is basically to archive a blob in an Azure Storage account. So remember that in Azure Storage accounts in the Blob service. So let’s say you have this object over here, so you can see the access tire is hot. That means you can easily go ahead and retrieve the object. But sometimes companies want to archive objects that are not being used at all. So when you place an object in Archive Storage, it actually saves on the cost. So when you have thousands and thousands of objects, you can actually go ahead and actually move it to Archive Storage if you still require it, but don’t require to access it at that point in time onto Archive Storage. Now, the way that you actually change the tier is to basically click on this Change Tier, choose your Tier, and then click on Archive.

But then in today’s world, you need to have an automated way in order to have this done. So you can go on to every object and just change it to Archive. You should have some method of archiving objects which are probably a week old or two weeks old or a month old. So that can be done with the help of Azure Logic apps. So currently we’re going to leave this object as it is, so it’s going to be in the access tier of Hot. Let’s go on to Logic app design. Let’s go on the designer itself. So I’ll go on templates. I’ll click on okay, so if you scroll down, you actually have a template to order Tier Azure Blobs based on the last modified date. So let me choose that. So I’ll say users. Template. So I’ll choose my existing Azure Blob storage account. Click on continue. And now you can see that you have an entire workflow in place. So this is the meaning of a template.

So template already has a workflow with triggers and a lot of steps already in place. So over here you can see that you have a recurrence. So how often do you want this workflow to run? Since this is just a demo, again, I’ll choose seconds. Let me choose an interval of 5 seconds. So this workflow will run every 5 seconds. Next you have to set what should be the Tier age variable so this basically means that if you place a value of -180 that means those objects which are 180 days old, those will be automatically set on to the Archive Tier. So if you have an object that has been uploaded or has been modified and it’s in the Hot tier, and if no activity has been performed on that object for the past 180 days, then it will be changed onto the Archive Tier. Now, since this is just a demo, I want to show you how immediately it can change an object onto the Archive tier. So I’ll put the value of zero next. In the next step, I need to choose my container.

So let me choose that. And then for each Blob in that particular container, let me go ahead and click the advanced Mode. So here it has a formula wherein it is checking for the last modified date for each Blob object, adding the days of the tier age in days. So this is how it calculates whether the object is basically older than the tier value. If it is true, then let’s change the Blob tier to Archive. If it is false, you can perform another action. Let me go ahead and click on Save, right? So this is done if I go back onto Azure Blob storage. Let me wait for 5 seconds. Let me hit on Refresh. And now you can see that the access tier has been marked automatically. Has archive, right? So you’ve seen how you could use the Inbuilt templates to also quickly start with working with Azure project apps. This marks the end of this lab.

  1. AZ-203 – What is the Azure Search Service

Hi and welcome back. Now in this chapter, let’s have an introduction to the Azio Search Service. So when would you want to use a search service? So let’s say you have an application that’s connecting to a data store. So there’s a lot of data in this data store. Let’s say you want as part of this application to give the the ability for users to search this data. So even if we look at the most popular search engine of Google, this allows you to search data over a big data store. So in such a case, what you can do is that you can use the fully managed service of Aze, your search. Now, when you are using the Azeo Search service, some important concepts, and we are going to look at this in more detail into subsequent chapters.

The first thing that you do in Azure Search is to create an Azure Search account. Now within an account itself, you’ll create something known as an index. That index will be part of your Azure search account, just like you have an index on a table in, let’s say, an Azure SQL database. That index is normally used to basically go to a record when you fire a query against a table. Similarly, you’ll have an index which will be connected to your data store or at least to the data itself. Now the index will actually go ahead and create a list of documents based on the searchable data in your data store.

So when you go ahead and query the index in your search account, you will actually get a list of documents with the data pertinent to your data store. So here I’m just giving an example of documents that can be part of a particular index. So here I have three documents in the index and here you have the data that’s part of the document itself. So an index is like a table in a traditional SQL database and the documents are like rows of a table. So this was just a quick introduction on to the Azure Search service. We are going to go into subsequent chapters to understand more on the Azure Search service.

  1. AZ-203 – More on Azure Search Service

Hi and welcome back. So now that we have an introduction on to Azure search, let’s look at some more aspects on the Azure Search service. So first is your index. So remember, your index is like having a table in a normal SQL relational database. So in Azure search, an index is a persistent store of documents. The index also contains other constructs that are used for filtered and fulltext search. Now within the index you have multiple documents. Our document is basically in JSON format and it’s a single unit of searchable data in the index. So I said the index is like a table and the documents are like rows of that table. Each index consists of fields and each field is associated with a data type. In a later on chapter, we will see how to provision and Azure Search account and also how to provision an index in the search account and how to add documents to the index.

Now, the index will also consist of one field that will become the key of the index. This is used to uniquely identify a document within the index itself. So one of the fields in that index needs to be defined as the key. Now apart from that, you can also add additional attributes for a field in the index. So these attributes are so you could mark a field as retrievable. This decides whether the field would come up in the search result. We can also mark a field as Filterable. This decides whether the field can be used in Filter queries. You then have the sortable attribute. This decides whether the field can be used to sort the search results using a fastable. This can be used to group multiple documents together. And then you have searchable which allows the field to be full text searchable. We are going to be looking at details how we can use these additional attributes for an index.

Now, when you perform a search and you can perform different type of searches in the Azure Search account, each search result document has a score attached. This score is basically used to rank documents that best answer a user question that is expressed by the search query. We also have the concept of an indexer which we’re going to see also in a lab. So an indexer can be used to extract searchable data and metadata. The indexer can fetch this data from an external data source. It then auto populates the index with fields. The indexer can also be scheduled to see changes in the data in the data source. So this external data source can be an Azure SQL database or Azure Blob storage. You can then connect the Azure Search account index itself on to this external data source using an indexer. And we’re going to be seeing this in a lab as well, right? So this marks the end of this chapter. Now let’s move on to the next chapters. In this course.

  1. AZ-203 – Lab – Azure Search Service

Hi and welcome back. Now in this lab, let’s see what we’re going to do. So first we’re going to go ahead and create a new Azure search account. We’re then going to create an index in the account, and then we’re going to see how we can upload documents via the rest API. So let’s go ahead with our lab. So here we are in Azure. Now let’s go ahead and create a new resource so we can search for the Azure Search service. We can go ahead and create an instance of that service. We can choose a resource group, give a service name. You can keep the location hazardous. Now we can go on to the pricing tier. Now, depending upon the number of resources that you want, the number of indexes that you want, if you are looking at using your search account in a productionbased environment, then you should use or consider using a higher pricing offering that’s available with Azure Search.

Since we are just doing a demo, I’m going to choose the basic pricing tier and click on select. Let me go ahead onto scaling. So I’ll leave the scaling hazardous. I won’t add any tags. Let’s go on to review and create and let’s go ahead and create a search service. Let’s come back once the search service is in place. Now once search account is in place, you can go on to the resource. So in the overview, you can see the amount of storage that you’re using. So, based on the pricing tier, you have a quota of two GB. You can see the number of indexes that you have. So remember that indexes are like having tables in a normal relational database. So currently you have a quota of 15. Indexes are used if you want to crawl or if you want to use existing data sources that are available in Azure.

So, for example, if you want Azure search to connect to an Azure SQL database or to Azure Blob storage, you can go ahead and work with indexes, right? So now let’s go ahead on to indexes. Let’s create a new index. We can click on Add Index over here. You can give an index name. And now you can go ahead and add the fields. Now please know that you need to have one field in place in the index, which becomes the key. It helps to uniquely identify a document in the index. So we only have one field in place. You can see that there is a type for the field itself, and then you have the attributes of retrieval, filterable, sortable, Fastable, and Searchable. Now let’s go ahead and add a field. So to add a field, you can give the field name. You can decide on the type and you can decide on what you want to add has the attribute for this field.

Please know that after you create an index and you decide on the attributes for the fields in that particular index, you can’t change the attributes later on. So let’s say for the name field that you want to mark the field as, let’s say Sortable. Please do it now after the index is in place, you can’t change the attribute for the field itself, the only attribute that you can change is the retrievable attribute. But apart from that, you can’t make any changes to the other attributes of the field after the index is in place. So let me go ahead and add the fields which are going to be part of this particular index. So I’ve gone ahead and added the fields to this index. So I’ve made the name field has Filterable. I have added a field name of course which is of the Type string. I’ve made it fastable. I have added a field known as Progress. This is of the Type integer I’ve made.

This field has Sortable and then I have a field known as Comment. This is of the Type string and I have made this field as Searchable. I’m using the standard analyzer of Standard Lucine. So let’s go ahead and create this index, right? So now the index is in place. Currently we have no documents as part of this index. Now currently you can’t add the documents directly in the index from the Azure Portal you have to use other ways of adding documents to your index. So one of the ways we are going to see this is via the rest API. So now let’s go ahead with how we are formulating our request in the postman tool. So we are currently going to be using this request to upload documents onto our search service. So first is the URL itself, or before that, first is the method. So since we are uploading documents, we’re going to be using the post method. Next is the URL.

So first you have your search account. So if I go on to the search account itself, you can actually take the URL from here. So you have your search account name search Windows Net, then you have Indexes. What is the name of the index? So remember, the name of the index is Customer. And then we have Docs and we have Slash index. Now next, if you go on to the headers, we need to add two headers. So first is the content type. So the content type is application JSON. And then we have to add the API key. So from where do we get the API key? So if you go back onto your search account, if you go on to keys here you have your primary admin key and your secondary admin key. Let’s go ahead and copy the key. You can copy either one, the primary or the secondary.

Let’s go over back onto Postman and add the key over here. So that is in place. Now let’s go over on to the body of the request. So these are the documents which you want to add on to your index in your search account. So we have to wrap all of the documents that we want to upload has values. Please know that in a zero search, each document is in JSON format, so we have all key value pairs. So first is the search action. So we have to mark this as upload, which means that this is the document that’s going to be uploaded onto our index. We then mention what would be the values. So remember that we already have our fields in place. So we have the ID, the name, the progress, the comment and the course. Now I’m adding three documents over here on to our index. Let’s go ahead and click on Send. So over here it’s giving me invalid or missing API version.

So I’ve just gone ahead and added the API version over here. Let me again click on Send. And now you can see that we’ve got the output. So we’ve got key one, key two, and key three. Let’s go over onto Azure Index. Now, it will take time for the documents to be refreshed over here, so you can keep on clicking the refresh button to see if the document list is being increased. Now, after some time, you can see that you now have a document count of three in your index and you now have a storage size. You can go on to the index. You can do an open search, so you can click on Search. So here in the query string, we are not mentioning anything. Now here you can see you’re getting your three documents. Each document has a search score.

And currently, since you’ve only marked the ID field and the name field as retrievable, only those fields are being returned as part of your search result. Now, if you go on to the fields itself. So remember, these are the fields of your index. You can see that you can mark. Now the other fields has retrievable as well, but you can’t make changes to the other attributes of the other fields. Let me go ahead and click on Save. We can go back to the Search Explorer, click on Search. And now you can see you’re getting all the fields as part of your search result, and that is because you’ve now marked them as retrievable, right? So in this chapter we have seen a lab on how to work with Azure Search.