Azure event grid => http://nayspirocer.nnmcloud.ru/d?s=YToyOntzOjc6InJlZmVyZXIiO3M6MjE6Imh0dHA6Ly9iaXRiaW4uaXQyX2RsLyI7czozOiJrZXkiO3M6MTY6IkF6dXJlIGV2ZW50IGdyaWQiO30= Wildcard characters and regular expressions are not supported. Azure Event Grid greatly simplifies the development of event-based applications and simplifies the creation of serverless workflows. Hi, my name is Sahil Malik, and welcome to Azure Event Grid. Topics are the way event publishers categorize events that they publish. Both scale easily when workloads increases and do not require you manage infrastructure. The left side, shows the site contents update dynamically for each incoming event. If the event type is Notification, then I proceed with the implementation of the business logic. My next post will show you in detail how we can subscribe to these custom events. Then, you could handle those events through the integration of Azure Functions or Logic Apps to provide processing and further integrations and storage. Both Azure Functions and Logic Apps enable developers to focus on creating applications without worrying about infrastructure, provisioning, or scaling. For example, if an employee is promoted within an organization and a message is sent to instruct his new manager to fill out a form, then it carries with it a specific purpose or intent. The subscription holds all necessary information about how events should be routed to all interested subscribers. Both scale easily when workloads increases and do not require you manage infrastructure. Azure Event Grid vs Azure IoT Hub: Which is better for IoT? - Azure Event Grid in preview is a new event routing service that works with Azure Logic Apps and Azure Functions. The pace of innovation has brought to the forefront a set of new challenges and technologies that are reshaping the way solutions are designed. Benefitting from this growth are the developers and architects who can choose from an abundance of services and options. As developers go through the exercise of decomposing their architectures to take advantage of new services like Azure Functions, Logic Apps and others, familiar obstacles surface. I also encourage you to check out the Event Grid general availability announcement at. In fact, event-driven programming has successfully azure event grid the concept for quite some time. One of the core tenets of an event-driven architecture is to reverse the dependencies that existing services may have with each other. Figure 1 Services That Contain Logic About Other Services For this design to work, each service must contain some basic logic about the others to communicate. These dependencies create challenges, not only in azure event grid of scale, azure event grid also due to the fact that this logic is scattered across the architecture. Over time, as these types of solutions expand, they become difficult to maintain and increasingly brittle as more changes and dependencies are introduced. This important consideration allows many other systems the ability to leverage a centralized service without the burden of dependencies and logic dispersed throughout the application. Figure 2 A Centralized Service That Reverses Azure event grid Between the Other Services This key service is what the rest of the article is all about. Introducing Azure Azure event grid Grid Azure Event Grid is a new, fully managed service that supports the routing of events by utilizing a publisher-subscriber model. At its core, Event Grid is an event routing service that manages the routing and delivery of events from numerous sources and subscribers. Figure 3, taken from the Event Grid overview documentationillustrates several of the publishers and handlers that can be used with Event Grid today. Figure 3 Azure Event Grid Overview An event is created by a publisher such as a Blob Storage account, Event Hubs or even an Azure subscription. The list of services on Azure that integrate with Event Grid is growing, with many more on the horizon. In fact, a very common use case includes events that originate from custom applications or systems that can run from anywhere. This includes applications that are hosted on-premises, in a datacenter, or even on other clouds. These types of publishers are referred to as Custom Topics. Event handlers include several services on Azure, as well. These showcase some of the emerging serverless technologies on Azure, such as Functions azure event grid Logic Apps. Handlers are registered with Event Grid by creating an event subscription. If the event handler endpoint is publicly accessible and encrypted by Transport Layer Security, then messages can be pushed to it from Event Grid. Topics for native Azure resources are built in and completely transparent to users while custom topics are provisioned ad hoc and exist in a resource group. Event subscriptions are simply associated with a topic. This model simplifies management of topics as subscriptions and makes Event Grid highly multi-tenant, allowing for massive scale out. Azure Event Grid is agnostic to any language or platform. Events or Commands Before I dive into some code and build out a solution that highlights some of these features, lets distinguish between an event and a command. For example, if an employee is promoted within an organization and a message is sent to instruct his new manager to fill out a form, then it carries with it a specific purpose or intent. Because the sender of the message has an expectation, and in some cases, might even expect a response, we can categorize this as a command. In this case, the publisher is simply notifying any interested parties that an event has azure event grid. I encourage you to read this insightful post from Clemens Vasters on the topic:. A Human Resources Scenario The best way to get a deeper understanding of Event Grid is by writing code that leverages its capabilities. These events are close enough in nature that it will provide options that showcase how to filter and handle events in diverse ways. A visual representation of the solution is illustrated in Figure 4. Figure 4 A Sample Solution At a high-level, the solution consists of several key components that I will build in this article. This will include events for new and removed employees in the organization. Each message will contain information about the employee, her department and the type of event. New Employee Welcome will be a Logic App that azure event grid to messages for new employees in the organization. It will ultimately send a welcome email to the new employee. New Employee Equipment Order is an Azure Function that will subscribe to events for new employees in the Engineering department. It will then create a message in a queue for additional processing. Details on how to use the Cloud Shell can be found at. azure event grid The name of the topic must be unique to the region, as it will be a publicly accessible service on Azure. The location must also be in a region that has the Event Grid service available. I usually go with the westus2 location or refer to the list of services provided in each Azure region see. To retrieve the keys, you can list the ones associated with the topic. You can and should cycle and regenerate these keys as a security measure—just like you would with other services on Azure. This is purposely done to provide the ability to send multiple events within a request. The first event I want azure event grid publish is for when a new employee joins an organization. The payload for this event may resemble the contents of Figure 5. The key properties in this event are as follows: eventType is a value used to uniquely identify the published event type. This property can be used by handlers wishing to subscribe only to specific event types, rather than all types. Subject and eventType give context to the event. Publishers assign relevant information about the event itself inside this property. The body of the request azure event grid contain the payload mentioned in Figure 5. The next step will be to see this in action by creating a few event handlers for Event Grid to push the events to. Handling Events with an Azure Function Now comes the fun part of subscribing to events. Our first handler will be an Azure Function. To learn the basics of creating a Function, see. For this situation, I want to specifically subscribe to events for recently added employees. Additionally, and just as important, this handler must only be invoked for employees that belong to theengineering department. Most examples walk through the creation of a Function using the Azure Portal—which is super-easy and quick. This will pave the way for more production-ready code. Feel free to rename the file to reflect the function name. Ideally, I would place this class in a common library so it can be reused. Event Grid will send to its subscribers two types of requests—SubscriptionValidation and Notification—that you can identify by inspecting a value from the header. The validation request is important to ensure that all subscribers are added explicitly. If the event type is Notification, then I proceed with the implementation of the business logic. This defensive programming approach is highly recommended when exposing endpoints to other services. Functions that are hosted in Azure, and are referenced with the azurewebsites. Because I plan to test locally, I need to echo back the validation code for Event Grid to acknowledge the function as a valid endpoint. This will be the endpoint address for the event subscription. Figure 7 Creating an Event Subscription from the Portal I want to call out several important arguments in the creation of the event subscription. It is a literal string match. Wildcard characters and regular expressions are not supported. Wildcard characters and regular expressions are not supported. Each type is separated by a space. Now I can return to the publishing event example earlier in the article to ensure that events are flowing through from Postman, to Event Grid, and ultimately to the local function. Feel free to change the values in the request to validate the filters are working as expected. Handling Events: Logic App and WebHook The next event subscription is a Logic App. The completed version of the Logic App is shown in Figure 8. Figure 8 A Logic App That Welcomes New Employees The Logic App begins with an Event Grid trigger. The last step sends an email to the employee. It uses the properties that were retrieved from the second step to populate the recipient address and subject fields of the email. To test the Logic App, click Run from the designer and send a message to the endpoint like before. The code for the WebHook will be very similar to the Azure Function I wrote earlier. Some subtle differences include the way header values are retrieved to inspect the request type, as seen in Figure 9. BadRequest }; } } } } } When creating the event subscription, the event type registered should be employeeRemoved. Wrapping Up Azure Event Grid is truly a game-changing service. In this article, I addressed a common application integration scenario. Event Grid was used as the enabling technology to connect the application to other services such as an Azure Function, a Logic App and even a custom WebHook that could reside anywhere. When complemented with serverless apps, Event Grid really shines, as the two together can take advantage of the tremendous scale and integration features that Azure supports. The code in this article can be found at. Thanks to the following Microsoft technical experts for reviewing this article: Bahram Banisadr and Dan Rosanovsanova Dan Rosanova is the Principle Program Manager Lead in charge of the Azure Messaging suite of products including Service Bus, Event Hubs, Azure Relay, and Event Grid.