Azure

Street To AZ-204 – Implement Azure Features

Intro

 

This text’s intention is to clarify the primary abilities measured on this sub-topic of the AZ-204 Certification. Azure Features and Azure Sturdy features are the primary parts that may have their fundamentals defined right here alongside a sensible instance.

 

This certification may be very intensive and this text approaches solely the primary matters, be sure you know deep down these parts earlier than taking the examination. One other nice tip is doing examination simulators earlier than the official examination to be able to validate your data.

 

What’s the Certification AZ-204 – Creating Options for Microsoft Azure?

 

The AZ-204 – Creating Options for Microsoft Azure certification measures designing, constructing, testing, and sustaining abilities of an utility and/or service within the Microsoft Azure Cloud setting. It approaches, amongst others, the next parts,

  • Azure Digital Machines;
  • Docker;
  • Azure Containers;
  • Service Net App;
  • Azure Features;
  • Cosmos DB;
  • Azure Storage;
  • Azure AD;
  • Azure Key Vault;
  • Azure Managed Identities;
  • Azure Redis Cache;
  • Azure Logic App;
  • Azure Occasion Grid;
  • Azure Occasion Hub;
  • Azure Notification Hub;
  • Azure Service Bus;
  • Azure Queue Storage.

 

Goal Viewers

 

Any IT skilled keen to enhance his data in Microsoft Azure is inspired to take this certification, it’s a good way to measure your abilities inside trending applied sciences. However, some teams of pros are extra eager to take most benefit of it,

  • Azure Builders, with a minimum of 1 12 months of expertise with Microsoft Azure;
  • Skilled Software program Builders, searching for an Architect place in a hybrid setting;
  • Software program Builders, working to maneuver purposes to the cloud setting.

Expertise Measured

 

In response to in the present day’s date, the abilities which can be measured within the examination are cut up as follows,

  • Develop Azure compute options (25-30%)
  • Develop for Azure storage (10-15%)
    • Develop options that use Cosmos DB storage
    • Develop options that use blob storage
  • Implement Azure safety (15-20%)
    • Implement consumer authentication and authorization
    • Implement safe cloud options
  • Monitor, troubleshoot, and optimize Azure options (10-15%)
    • Combine caching and content material supply inside options
    • Instrument options to assist monitoring and logging
  • Hook up with and eat Azure companies and third-party companies (25- 30%)
    • Develop an App Service Logic App
    • Implement API Administration
    • Develop event-based options
    • Develop message-based options

 

Advantages of Getting Licensed

 

The primary profit right here is having a worldwide acknowledged certification that proves that you’ve got data of this subject. Amongst intrinsic and extrinsic advantages, we’ve got:

  • Greater development potential, as certifications are an enormous plus;
  • Reductions and offers in Microsoft merchandise and companions, like PluralSight and UpWork;
  • MCP Newsletters, with trending applied sciences;
  • Greater publicity on LinkedIn, as recruiters often seek for particular certifications;
  • Greater wage, you may be extra priceless to your organization;
  • Distinctive happiness when getting the end result and also you have been authorised, figuring out that every one your efforts have been price it;

 

Essential abilities Measured by this Subject

 

What are Azure Features?

 

Azure Features is a part of the serverless companies supplied by Azure and as a serverless service, you don’t want to deal with the server infrastructure. With Azure Features your distinctive concern is about growing your code, setting the bindings, and configuring enter and outputs.

 

Azure Features is an open-source service and integrates with many different Azure Companies, for instance, Azure DevOps to create CI-CD to your Azure features to be able to automate your construct and deployment processes or Azure Storage to retailer your Azure Perform output. Azure Features additionally helps NPM and Nuget libraries.

 

Azure Features will be developed utilizing C#, Java, JavaScript, Python, and PowerShell. It has Three completely different fee plans, as follows, 

  • Consumption plan, you solely pay for the used time. Good for infrequent makes use of;
  • Within the premium plan, you may have a devoted machine so that you pay if you’re working your Azure Features or not,¬† as your machine shall be at all times up so that you keep away from Chilly Begin. Good for prime utilization;
  • App Service plan, run your Azure Features in your present App Service Plan infrastructure with no extra prices. Good you probably have an App Service Plan and don’t must scale your Azure Features.¬†

What are Azure Perform Bindings?

 

Once you join your Azure Perform to a different useful resource, to be able to set off your operate or retrieving and sending knowledge, known as a Binding. Azure Features assist all kinds of bindings choices for use, from HTTP Webhooks to SignaIR, and you should utilize your bindings in your Azure Perform in three completely different kinds, as follows:

  • Enter Binding, the place the info out of your useful resource goes to be your Azure Perform enter parameter;
  • Output Binding, the place your Azure Perform will write the output knowledge in your useful resource;
  • Set off Binding, the place an occasion in your useful resource goes to set off your Azure Perform.¬†

What are Azure Perform Triggers?

 

When an occasion happens that makes your Azure Perform run it is known as a set off. An Azure Perform will need to have at all times one set off that’s supposed to begin your Azure Perform each time that this occasion is fired.

 

Azure Perform has all kinds of triggers for use, from a brand new message in a Service Bus queue to a name to an API Endpoint, and people triggers are organized in three completely different kinds, as follows: 

  • Knowledge operations, these triggers can be utilized with all kinds of knowledge suppliers and are fired in keeping with when your knowledge has modified;
  • Timers, these triggers are fired in keeping with pre-configured time intervals;
  • Webhooks, these triggers are fired in keeping with a name to an API Endpoint request.¬†¬†

What are Azure Sturdy Features?

 

Azure Sturdy Features are an extension of the Azure Features the place they’ve the flexibility to have stateful workflows working in a serverless structure. By working in serverless structure, whereas Azure handles the Azure Perform state, checkpoints, and restarts, your solely fear is to supply your code and choose the Azure Sturdy

Perform sort and Azure Sturdy sample that most closely fits along with your resolution.

 

Azure Sturdy Features can be an open-source venture and has the value calculation precisely like Azure Features. 

 

Azure Sturdy Features Varieties 

 

Azure Sturdy features are long-running features used to course of knowledge following a designed stateful procedural workflow. It has 4 differing types, every sort representing one function, the place they work together amongst themselves to be able to signify your workflow, as follows:

 

Consumer Kind

 

Consumer Features are the kind of Sturdy Perform used to work together, by triggering or calling different Sturdy Features, their major options are as follows,

  • Have a Sturdy Consumer Output Binding;
  • Used to set off Orchestration and Entity Features, through the use of the Orchestration Consumer Binding or Entity Consumer Binding;
  • Can work together with working Orchestration and Entity Features;

Orchestrator Kind

 

Azure Sturdy Orchestrator Features are used to design the workflows with its models of labor, they will need to have the identical output end result regardless of what number of instances it was executed. Its major options are as follows,

  • Has code constraints, to be able to hold it being deterministic;
  • Used to design complicated workflows;
  • Are executed when prompted by its Orchestration Set off;
  • Are sturdy and dependable.

 

Exercise Kind

 

Azure Sturdy Features of the Exercise sort are the features used to prepare duties contained in the Sturdy Orchestration Features. Every exercise should signify one job out of your workflow inside your Sturdy Orchestration Perform. Its major options are as follows,

  • Can solely be triggered from an Orchestration Perform;
  • Are the unit of labor from the Orchestration Features;
  • May be executed sequentially, in parallel, or each;
  • Are nice at dealing with enter and outputs.

Entity Kind

 

Azure Sturdy Features of the Entity sort are often a small piece of code used to govern states, like a category with its strategies manipulating its properties, whereas they might work together with one other Entity Perform, an Orchestration Perform, and Consumer Features. Its major options are as follows,

  • Used to replace Entities states;
  • Has an inner id, consisted of the pair Entity Identify and Entity Key;
  • Might have or not a particular state;
  • Are executed when prompted by its Entity Set off;
  • Its operations are executed serially, one after one other, to forestall conflicts;

 

Azure Sturdy Features Patterns

 

https://docs.microsoft.com/en-us/azure/azure-functions/sturdy/durable-functions-overview?tabs=csharp#application-patterns

  • Perform Chaining Sample, chaining one operate output into one other operate’s enter;
  • Fan-out/Fan-in Sample, executing a number of features in parallelism after which ready for them to complete;
  • Async HTTP API Calls Sample, used with often 2 endpoints whereas one begin the long-running operate and the opposite supplies particulars about its standing;¬†
  • Monitor Sample, works as a recurring course of used to watch standing till having particular circumstances met;
  • Human Interplay Sample, workflow waits for human interplay;
  • Aggregator Sample used to combination knowledge from a number of supply inputs right into a single entity.¬†

Azure Sturdy Features will be developed utilizing C#, JavaScript, Python, F#, and PowerShell.

 

Creating an Azure Perform 

 

There are numerous alternative ways to create your Azure Perform however we shall be approaching the two most used methods, by way of Visual Studio and Azure Portal.

 

Creating Azure Perform by way of Azure Portal

 

Out of your Azure Portal, go to Useful resource after which Perform App. Click on on the Create button.

 

 

From the fundamentals menu, enter your Subscription, Useful resource Group, know-how stack, and the Azure Area. 

 

Road To AZ-204 - Implement Azure Functions

 

From the internet hosting menu, enter your storage account, operation system, and your plan.

 

Road To AZ-204 - Implement Azure Functions

 

Monitoring and Tags menus is not going to be approached right here so click on on the Evaluation + create button, after a couple of seconds Azure will end its validation and you’ll click on on the create button. After a couple of seconds for Azure to deploy your Azure Perform, you may be able to overview your Azure Perform.

 

Road To AZ-204 - Implement Azure Functions

 

Entry your Azure Perform URL

 

Road To AZ-204 - Implement Azure Functions

 

Now let’s add logic to our Azure Perform. Out of your Azure Perform, go to the Features menu after which on Features click on on Add.

 

Road To AZ-204 - Implement Azure Functions

 

From the templates menu, decide the HTTP set off, title the operate, choose the authorization stage, and create. After a couple of seconds, you may be redirected to your HttpTrigger already with some code on it 

 

Road To AZ-204 - Implement Azure Functions

 

Click on on Check/Run to see the end result out of your Azure Perform 

 

Road To AZ-204 - Implement Azure Functions

 

You might additionally click on on Get Perform URL and take a look at your HTTP set off end-to-end. Copy your URL and take a look at it on a browser, right here I had added my title as a question string to be able to have this end result.

 

Road To AZ-204 - Implement Azure Functions

 

Creating Azure Perform by way of Visual Studio utilizing C#

 

To make use of Azure initiatives along with your Visual Studio you will need to have the Azure Growth workload put in.

 

Add a brand new venture of sort Azure Features, title your venture as AzureFunctionVisualStudio

 

Road To AZ-204 - Implement Azure Functions

 

Choose the HTTP Set off alongside along with your storage account and authorization stage. Then click on on the create button.

 

Road To AZ-204 - Implement Azure Functions

 

Your venture construction and performance file should seem like this. I had accomplished some small adjustments to customise the Perform.

 

Road To AZ-204 - Implement Azure Functions

 

In case you push F5 it is possible for you to to check your Azure Perform

 

Road To AZ-204 - Implement Azure Functions

 

To publish on Azure and deploy your Azure Perform, right-click in your venture after which click on on Publish. 

 

Road To AZ-204 - Implement Azure Functions

 

Choose Azure after which Azure Features (Home windows). Click on on Create a brand new Azure Perform.

 

Road To AZ-204 - Implement Azure Functions

 

Choose your subscription, useful resource group, plan sort, Azure location, Azure storage and click on on create.

 

Road To AZ-204 - Implement Azure Functions

 

After success validation from Azure, click on on end. You’ll be prompted along with your publish profile, validate your knowledge, and click on on Publish.

 

Road To AZ-204 - Implement Azure Functions

 

After profitable deployment, validate your Azure Perform by way of Azure Portal

 

Road To AZ-204 - Implement Azure Functions

 

Copy your Perform Url and take a look at it by way of your browser. I’ve added a customized title as queryString right here.

 

Road To AZ-204 - Implement Azure Functions

Implementing Enter and Output Bindings for a Perform

 

As you’ll be able to see, the earlier train has already made use of Enter and Output Bindings. The enter binding is of sort httpTrigger and the output sort is of sort HTTP.

 

Road To AZ-204 - Implement Azure Functions

 

Implementing Output Bindings with Azure Storage for a Perform

 

Inside your Azure Perform, go to Integration after which Add output

 

Road To AZ-204 - Implement Azure Functions

 

Choose your Binding Kind with its configuration. Right here we shall be writing to a Blob Storage named sampleOutputBlob.

 

Road To AZ-204 - Implement Azure Functions

 

After profitable deployment, you will notice your outputs up to date

 

Road To AZ-204 - Implement Azure Functions

 

It’s time to replace your code to save lots of the output into the blob. You solely want one new line to configure this output, and the ultimate run.ps1 file appears like this,¬†

  1. utilizing namespace System.Internet  
  2.   
  3. # Enter bindings are handed in by way of param block.  
  4. param($Request, $TriggerMetadata)  
  5.   
  6. # Write to the Azure Features log stream.  
  7. Write-Host¬†“PowerShell¬†HTTP¬†set off¬†operate¬†processed¬†a¬†request.”¬†¬†
  8.   
  9. # Work together with question parameters or the physique of the request.  
  10. $title = $Request.Question.Identify  
  11. if (-not $title) {  
  12.     $title = $Request.Physique.Identify  
  13. }  
  14.   
  15. $physique¬†=¬†“This¬†HTTP¬†triggered¬†operate¬†executed¬†efficiently.¬†Go¬†a¬†title¬†in¬†the¬†question¬†string¬†or¬†in¬†the¬†request¬†physique¬†for¬†a¬†customized¬†response.”¬†¬†
  16.   
  17. if ($title) {  
  18. ¬†¬†¬†¬†$physique¬†=¬†“Good day,¬†$title.¬†This¬†HTTP¬†triggered¬†operate¬†executed¬†efficiently.”¬†¬†
  19. }  
  20.   
  21. #¬†Affiliate¬†values¬†to¬†output¬†bindings¬†by¬†calling¬†‘Push-OutputBinding’.¬†¬†
  22. Push-OutputBinding -Identify Response -Worth ([HttpResponseContext]@{  
  23.     StatusCode = [HttpStatusCode]::OK  
  24.     Physique = $physique  
  25. })  
  26.   
  27. Push-OutputBinding -Identify sampleOutputBlob -Worth $physique  

Road To AZ-204 - Implement Azure Functions

 

Execute your operate to check your new output. Then, go test the blob knowledge

 

Road To AZ-204 - Implement Azure Functions

 

Implementing Perform Triggers by Utilizing Webhooks

 

The names right here have to be complicated generally however utilizing a Webhook is similar as utilizing an HTTP Set off identical to we used above. It’s precisely the identical set off however it’s known as generally by Webhook and another instances by HTTP Set off.

 

Implementing Perform Triggers by Utilizing Knowledge Operations

 

Now let’s create one other set off to be fired when a Blob file is created. We shall be studying blobs from the outcontainer and writing it into secondoutcontainer.

 

Out of your Azure Perform, beneath Features then add a brand new Azure Blob storage set off.

 

Road To AZ-204 - Implement Azure Functions

 

Road To AZ-204 - Implement Azure Functions

Enter the blob title, storage account and path. After creating the operate, test on Integration so as to add a brand new Output.

 

Road To AZ-204 - Implement Azure Functions
Road To AZ-204 - Implement Azure Functions

 

Your run.ps1 should seem like this

  1. # Enter bindings are handed in by way of param block.  
  2. param([byte[]] $InputBlob, $TriggerMetadata)  
  3.   
  4. # Write out the blob title and measurement to the data log.  
  5. Write-Host¬†“PowerShell¬†Blob¬†set off¬†operate¬†Processed¬†blob!¬†Identify:¬†$($TriggerMetadata.Identify)¬†Dimension:¬†$($InputBlob.Size)¬†bytes”¬†¬†
  6. Push-OutputBinding -Identify outputBlob -Worth $($TriggerMetadata.Identify)  

Checking end result

 

Road To AZ-204 - Implement Azure Functions

 

Implementing Perform Triggers by Utilizing Timers

Let’s create a brand new timer set off that may write one other blob file with the time on it. This output container shall be named outtimercontainer.

 

Out of your Azure Perform, beneath Features then add a brand new Timer set off. 

 

Road To AZ-204 - Implement Azure Functions

 

Set your scheduler for working each every 2 minutes

After configuring your output, adjusting your run.ps1 recordsdata should seem like

  1. # Enter bindings are handed in by way of param block.  
  2. param($Timer)  
  3.   
  4. # Get the present common time in the default string format.  
  5. $currentUTCtime = (Get-Date).ToUniversalTime()  
  6.   
  7. #¬†The¬†‘IsPastDue’¬†property¬†is¬†‘true’¬†when¬†the¬†present¬†operate¬†invocation¬†is¬†later¬†than¬†scheduled.¬†¬†
  8. if ($Timer.IsPastDue) {  
  9. ¬†¬†¬†¬†Write-Host¬†“PowerShell¬†timer¬†is¬†working¬†late!”¬†¬†
  10. }  
  11.   
  12. # Write an data log with the present time.  
  13. Write-Host¬†“PowerShell¬†timer¬†set off¬†operate¬†ran!¬†TIME:¬†$currentUTCtime”¬†¬†
  14.   
  15. Push-OutputBinding -Identify outputBlob -Worth $currentUTCtime  

Checking end result

 

Road To AZ-204 - Implement Azure Functions

 

Implementing Azure Sturdy Features with Visual Studio and C#

 

On this sensible pattern, we’re going to apply the four forms of Sturdy Features within the following situation which consists of calling¬†one relaxation API and rely the variety of chars in its output. It’s triggered by an HTTP Set off.

 

Pre-requisites

Create the Mission of sort Azure Features

 

Road To AZ-204 - Implement Azure Functions

 

Right here I’ll title it as DurableFunctionsSample.¬†

 

Road To AZ-204 - Implement Azure Functions

 

Let’s begin with an empty venture and use the Storage Emulator as a storage account

 

Road To AZ-204 - Implement Azure Functions

 

Right here is the end result from the venture creation

 

Road To AZ-204 - Implement Azure Functions

 

Proper-click on the venture after which Add after which New Azure Perform. Right here I’ll title it as OrchestrationSample.

 

Road To AZ-204 - Implement Azure Functions

 

Road To AZ-204 - Implement Azure Functions

 

Visual Studio will create an Orchestration Perform class with code already on it. So, push F5 and test the output.

  1. public static class OrchestrationSample  
  2.    {  
  3. ¬†¬†¬†¬†¬†¬†¬†[FunctionName(“OrchestrationSample”)]¬†¬†
  4.        public static async Activity<Record<string>> RunOrchestrator(  
  5.            [OrchestrationTrigger] IDurableOrchestrationContext context)  
  6.        {  
  7.            var outputs = new Record<string>();  
  8.   
  9.              
  10. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†outputs.Add(await¬†context.CallActivityAsync<string>(“OrchestrationSample_Hello”,¬†“Tokyo”));¬†¬†
  11. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†outputs.Add(await¬†context.CallActivityAsync<string>(“OrchestrationSample_Hello”,¬†“Seattle”));¬†¬†
  12. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†outputs.Add(await¬†context.CallActivityAsync<string>(“OrchestrationSample_Hello”,¬†“London”));¬†¬†
  13.   
  14.              
  15.            return outputs;  
  16.        }  
  17.   
  18. ¬†¬†¬†¬†¬†¬†¬†[FunctionName(“OrchestrationSample_Hello”)]¬†¬†
  19.        public static string SayHello([ActivityTrigger] string title, ILogger log)  
  20.        {  
  21. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Saying¬†hey¬†to¬†{title}.”);¬†¬†
  22. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†return¬†$“Good day¬†{title}!”;¬†¬†
  23.        }  
  24.   
  25. ¬†¬†¬†¬†¬†¬†¬†[FunctionName(“OrchestrationSample_HttpStart”)]¬†¬†
  26.        public static async Activity<HttpResponseMessage> HttpStart(  
  27. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†[HttpTrigger(AuthorizationLevel.Anonymous,¬†“get”,¬†“post”)]¬†HttpRequestMessage¬†req,¬†¬†
  28.            [DurableClient] IDurableOrchestrationClient starter,  
  29.            ILogger log)  
  30.        {  
  31.              
  32. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†string¬†instanceId¬†=¬†await¬†starter.StartNewAsync(“OrchestrationSample”,¬†null);¬†¬†
  33.   
  34. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Began¬†orchestration¬†with¬†ID¬†=¬†‘{instanceId}’.”);¬†¬†
  35.   
  36.            return starter.CreateCheckStatusResponse(req, instanceId);  
  37.        }  
  38.    }  
Road To AZ-204 - Implement Azure Functions

 

Calling the endpoint

 

Road To AZ-204 - Implement Azure Functions
Road To AZ-204 - Implement Azure Functions 

 

Customizing the Azure Sturdy Perform

 

Now we’re customizing this sturdy operate to be able to have our situation utilized. The Azure Sturdy Perform have to be triggered by an HTTP Set off and should return the chars rely from a relaxation API.

 

Consumer Perform End result

 

The shopper operate shall be up to date to obtain the endpoint URI as a question string enter and ship it to the Orchestrator Perform. 

  1. [FunctionName(“OrchestrationSample_HttpStart”)]¬†¬†
  2.      public static async Activity<HttpResponseMessage> HttpStart(  
  3. ¬†¬†¬†¬†¬†¬†¬†¬†¬†[HttpTrigger(AuthorizationLevel.Anonymous,¬†“get”,¬†“post”)]¬†HttpRequestMessage¬†req,¬†¬†
  4.          [DurableClient] IDurableOrchestrationClient starter, ILogger log)  
  5.      {  
  6.          var qs = req.RequestUri.ParseQueryString();  
  7. ¬†¬†¬†¬†¬†¬†¬†¬†¬†object¬†endpoint¬†=¬†qs.Get(“endpointUri”);¬†¬†
  8.   
  9. ¬†¬†¬†¬†¬†¬†¬†¬†¬†string¬†instanceId¬†=¬†await¬†starter.StartNewAsync(“OrchestrationSample”,¬†endpoint);¬†¬†
  10. ¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Began¬†orchestration¬†with¬†ID¬†=¬†‘{instanceId}’.”);¬†¬†
  11. ¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Endpoint¬†=¬†‘{endpoint}’.”);¬†¬†
  12.   
  13.          return starter.CreateCheckStatusResponse(req, instanceId);  
  14.      }  

Orchestration Perform End result

  1. [FunctionName(“OrchestrationSample”)]¬†¬†
  2.         public static async Activity<string> RunOrchestrator(  
  3.             [OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)  
  4.         {  
  5.             string endpoint = context.GetInput<object>().ToString();  
  6.             var request = new DurableHttpRequest(HttpMethod.Get, new Uri(endpoint));  
  7.             DurableHttpResponse endpointResponse = await context.CallHttpAsync(request);  
  8.             if (endpointResponse.StatusCode != HttpStatusCode.OK)  
  9.             {  
  10. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†throw¬†new¬†ArgumentException($“Failed¬†to¬†contact¬†endpoint:¬†{endpointResponse.StatusCode}:¬†{endpointResponse.Content material}”);¬†¬†
  11.             }  
  12. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Data¬†retrieved¬†from¬†endpoint¬†=¬†{endpointResponse.Content material}.”);¬†¬†
  13.   
  14. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†string[]¬†phrases¬†=¬†endpointResponse.Content material.Break up(”¬†“);¬†¬†
  15. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Phrases¬†rely¬†=¬†{phrases.Depend()}.”);¬†¬†
  16.   
  17. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†var¬†entityId¬†=¬†new¬†EntityId(“OrchestrationSample_Counter”,¬†“charCounter”);¬†¬†
  18. ¬† ¬† ¬† ¬† ¬† ¬† context.SignalEntity(entityId,¬†“reset”);¬†¬†
  19.   
  20.             foreach (string phrase in phrases)  
  21.             {  
  22. ¬† ¬† ¬† ¬† ¬† ¬† ¬† ¬† context.SignalEntity(entityId,¬†“Add”,¬†phrase);¬†¬†
  23.             }  
  24.   
  25. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†await¬†context.CallActivityAsync(“OrchestrationSample_LogBlob”,¬†endpoint.Change(“/”,¬†“bar”));¬†¬†
  26. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†int¬†rely¬†=¬†await¬†context.CallEntityAsync<int>(entityId,¬†“Get”);¬†¬†
  27.   
  28. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†return¬†$“Endpoint:¬†{endpoint}¬†has¬†the¬†whole¬†of¬†{rely}¬†chars”;¬†¬†
  29.         }  

Exercise Perform End result

 

The exercise operate shall be dumb right here, solely logging the endpoint title right into a blob.

  1. [FunctionName(“OrchestrationSample_LogBlob”)]¬†¬†
  2. ¬†¬†¬†¬†¬†public¬†static¬†async¬†Activity¬†LogBlobAsync([ActivityTrigger]¬†string¬†title,¬†[Blob(“sample-blob/{name}”,¬†FileAccess.Write)]¬†CloudBlockBlob¬†blobStream,¬†ILogger¬†log)¬†¬†
  3.      {  
  4.          await blobStream.UploadTextAsync(DateTime.UtcNow.ToString());  
  5. ¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Blob¬†Created¬†{DateTime.UtcNow}.”);¬†¬†
  6.      }  

Entity Perform End result 

  1. [FunctionName(“OrchestrationSample_Counter”)]¬†¬†
  2.       public static void Counter([EntityTrigger] IDurableEntityContext ctx, ILogger log)  
  3.       {  
  4. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†log.LogInformation($“Entity¬†operation=¬†{ctx.OperationName}.”);¬†¬†
  5.   
  6.           swap (ctx.OperationName.ToLowerInvariant())  
  7.           {  
  8. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†case¬†“add”:¬†¬†
  9. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†var¬†sum¬†=¬†ctx.GetInput<string>().Size¬†–¬†ctx.GetInput<string>().Depend(char.IsWhiteSpace);¬†¬†
  10.                   ctx.SetState(ctx.GetState<int>() + sum);  
  11.                   break;  
  12. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†case¬†“reset”:¬†¬†
  13.                   ctx.SetState(0);  
  14.                   break;  
  15. ¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†case¬†“get”:¬†¬†
  16.                   ctx.Return(ctx.GetState<int>());  
  17.                   break;  
  18.           }  
  19.       }  

Testing the Azure Sturdy Perform native

 

I distributed plenty of logging right here deliberately to be able to perceive higher how the Orchestration works. 

 

Road To AZ-204 - Implement Azure Functions 
Road To AZ-204 - Implement Azure Functions

 

Road To AZ-204 - Implement Azure Functions

 

Publish to Azure

 

Proper-click in your venture click on on Publish, choose Azure, after which Azure Perform App ( Home windows )

 

Road To AZ-204 - Implement Azure Functions

 

Create a brand new Azure Perform

 

Road To AZ-204 - Implement Azure Functions

 

Road To AZ-204 - Implement Azure Functions

 

After Azure validates and creates your Azure Perform then click on on End and you may be redirected to your publish profile. Now publish it.

 

Road To AZ-204 - Implement Azure Functions

 

After success deployment, validate your Azure Perform from Azure Portal

 

Road To AZ-204 - Implement Azure Functions

 

Check the Azure Sturdy Perform from Azure 

 

Name URL: https://durablefunctionssampletva.azurewebsites.web/api/OrchestrationSample_HttpStart?endpointUri=https://reqres.in/api/customers?web page=3 

 

Road To AZ-204 - Implement Azure Functions

 

Blob created 

 

Road To AZ-204 - Implement Azure Functions 

Exterior References

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button