Skip to Content
Technical Articles

Receive CloudEvents from Azure Event Grid with SAP Cloud Platform Alert Notification

As part of our integration initiative, today we’d like to demonstrate a simple scenario where the CloudEvents specification matches the SAP Cloud Platform Alert Notification event. Do you already receive SAP Cloud Platform events with SAP Cloud Platform Alert Notification service

For the setup, we chose the Microsoft Azure Event Grid as a native CloudEvents “speaker”. It will catch a blob creation event. Then the event will be delivered as an email message in the very same shape as any other SAP Cloud Platform Alert Notification event.

To walk through the scenario, we need just a couple of prerequisites:

 

Configure SAP Cloud Platform Alert Notification


This section includes both getting credentials for posting events to Alert Notification as well as instructioning the service what to do when an event arrives. Let’s start:

1. Instantiate Alert Notification, if you haven’t done so : )

  1. WIthin your Alert Notification instance view in the SAP Cloud Cockpit, create a technical client with BASIC authentication mechanism and ALERT_WRITE permission:
  2. Once created, you will be provided with client id and client secret – make sure to save them in a secure place, so that we could make use of them later.
  3. In the Export or Import menu, paste the following configuration in the Import text field and click Import:

    Note: Make sure to replace the email address placeholder with one you have access to.

    {
       "conditions":[
          {
             "name":"MatchAllCloudEvents",
             "propertyKey":"subject",
             "predicate":"EQUALS",
             "propertyValue":"CloudEvent received"
          }
       ],
       "actions":[
          {
             "name":"NotifyMeByEmail",
             "state":"ENABLED",
             "destination":"<<your_email_here>>",
             "type":"EMAIL"
          }
       ],
       "subscriptions":[
          {
             "name":"AllCloudEventsToMyEmail",
             "conditions":[
                "MatchAllCloudEvents"
             ],
             "actions":[
                "NotifyMeByEmail"
             ],
             "labels":[
                
             ],
             "state":"ENABLED"
          }
       ]
    }

     

  4. Within several seconds, you’ll receive an email containing a confirmation code as well as a confirmation link. Make sure to confirm you email action either using the link or the confirmation code in the SAP Cloud Cockpit.

You could later fine-tune the imported configuration to best match you needs. Playing around with conditions and combining them to subscriptions, you could achieve different granularity levels.

 

Prepare Your Microsoft Azure Account


In the next several minutes, we will configure an example setup that will be finally capable of sending CloudEvents towards Alert Notification. We will use a storage account where some blobs would be stored. Using Event Grid, we’ll subscribe for any update in the storage account. To complete the scenario, we’ll set up a Logic app that will forward the Event Grid events to Alert Notification.

Note: The storage account could be replaced by any event source and the Logic app could be replaced by any event handler that is capable of sending HTTP requests.

Let’s do it!

  1. Within the Azure Portal, create a resource group
  2. In the newly created resource group, create a general-purpose v2 storage account
  3. In the newly created storage account, create a container
  4. In the same resource group, create a Logic App
  5. Once your Logic app is successfully deployed, select Go to resource
  6. In Development Tools section, select Logic app designer, then When a HTTP request is received
  7. Copy-Paste the following snippet in Request Body JSON Schema:
    {
        "properties": {
            "data": {
                "type": "object"
            },
            "datacontenttype": {
                "type": "string"
            },
            "dataschema": {
                "type": "string"
            },
            "id": {
                "type": "string"
            },
            "source": {
                "type": "string"
            },
            "specversion": {
                "type": "string"
            },
            "subject": {
                "type": "string"
            },
            "time": {
                "type": "string"
            },
            "type": {
                "type": "string"
            }
        },
        "type": "object"
    }
    ​
  8. Select New Step, then HTTP
  9. Populate the required fields:
    • Select POST method
    • Build and enter the URI as follows depending on youр SAP Cloud Platform environment:
      • for your Cloud Foundry Alert Notification service instance – enter the url supplied with your Service Key, followed by /cf/producer/v1/resource-events?schema_definition=cloud_events&version=1.0, e.g.:
        https://clm-sl-ans-live-ans-service-api.cfapps.eu10.hana.ondemand.com/cf/producer/v1/resource-events?schema_definition=cloud_events&version=1.0
      • for Neo accounts – use the Event Producer URL shown at Security page when you navigate to Alert Notification service in SAP Cloud Platform Cockpit, with a similar ending, e.g.:
        https://clm-sl-ans-live-ans-service-api.cfapps.eu10.hana.ondemand.com/neo/producer/v1/resource-events?schema_definition=cloud_events&version=1.0
    • Add Content-Type header of type application/json
    • Select Basic Authentication type
    • Enter the previously created in Alert Notification client id as username
    • Enter the previously created in Alert Notification client secret as password
  10. Save the Logic app
  11. In the trigger section of the Logic App, copy the provided HTTP POST URL and save it as we’ll need it later
  12. Create an Event Grid System Topic with following properties:
    • Topic type – select Storage Accounts (Blob & GPv2)
    • Resource group – select the name of the resource group that we created in step 1)
    • Resource – select the name of the storage account that we created in step 2)
  13. Once deployment is done, select Go to resource and create an Event Subscription with following properties:
    • Event Schema – select Cloud Event Schema v1.0
    • Topic Name – if not already specified, select the name of the topic that we created in step 12)
    • Event Types – select all available choices (later you could finetune this)
    • Endpoint Type – select Web Hook
    • Endpoint – enter the URL we saved in step11)

Now our setup is ready to feed Alert Notification with CloudEvents. Let’s see it in action!

Execute the scenario


To test our setup, let’s upload a file to our storage account.

  1. Navigate to the storage account we created in step 2), then – the container we created in step 3)
  2. Select Upload
  3. Select some file from your computer – it could be any file you have on hand
  4. Click on the Upload button

Up to a couple of minutes, you’ll receive an email notification that a blob was just created.

 

For further information about the delivery of CloudEvents to SAP Cloud Platform Alert Notification, check the SAP Help Portal page.


This blog post is part of a series of blog posts related to integration between third-party monitoring tools and SAP Cloud Platform Alert Notification service. We will continuously add newly released integrations to the series, so stay tuned!

We ask you – our customers and partners – to join us in our integration journey! Tell us what you use for monitoring solutions, what you need to integrate with them; tell us your experience, and what your alerting needs are!

Be the first to leave a comment
You must be Logged on to comment or reply to a post.