Control your SAP runtime with Azure Logic Apps using Email {No-code}

“Everything is going to be connected to cloud and data…
All of this will be mediated by software.”
– Satya Nadella, CEO, Microsoft

Source: Bing

Do you remember how communication activities were handled in Email software in the 90s? With smartphone arrivals, things got totally changed. And, who would have imagined 30 years ago that we would carry the internet in pockets, homes would become our offices, bots will be answering your queries before connecting to your bank and other businesses, or simply paying using a smartphone as a credit card, or best part – getting our favorite food order by only using a smartphone app.
A similar important and significant shift is happening in Serverless space! It is getting more focus on business logic and code, not underneath servers or infrastructure. This isn’t the first time we’ve seen a massive shift in how technology affects our working lives, and it certainly won’t be the last, indeed.

While COVID-19 continues to make face-to-face collaboration an impossibility, cloud-based applications and workloads provide a well-defined method for remote development and project deployment, and Serverless applications already started playing an important role. Today this article will show you a good example of SAP and Serverless engine integration using Logic apps and SAP.

Serverless offerings, like Azure Logic Apps and Azure Functions, take this to the next level while allowing us, as developers, to focus only on our application functionality and not the backing infrastructure or uptime of servers. Also, here Azure Logic Apps and Azure Functions are big entry gates for non-coders and may finally be making the coveted ‘citizen developers’ idea a reality. Since the last decade, there has been the expectation that ‘citizen developers’ => non-coders and non-technical staff will be able to leverage the power of connectors and APIs through a range of visual design tools and drag and drop connectors. And I guess all Cloud providers are working on a similar goal! With the latest SAP and Azure integrations tools and processes, the focus is on getting on business logic built, not your servers.

Let’s explore and run a ‘hands-on’ session!

Source: Bing

Get Started!

We are going to build an Azure Logic App to save cloud resources cost running SAP Application. Here Logic App plays with the SAP system to automate shutdown (SAP and VMs both) using an Email handler. It is a convenient tool for Basis managers/Leads who wants to control SAP resources and IT budgets on the Cloud. I decided to build Logic Apps for SAP Infrastructure controlling purposes to integrate with SAP Application and VM altogether.

With this Logic Apps, Basis folks of any organization can take full control of shutting/starting the Sandbox/Development/Training/QA -SAP systems not being heavily used after business hours or over the weekends. Along with this idea, Basis Manager/Leader receives the list of logged-in users in Email as well before pressing the  ‘Shutdown’ button, only from Email. Sounds interesting!!

To build the Logic Apps, you can use one of the already existing templates. It’s a great way to learn and understand how the workflows are designed, and I highly recommend spending some time reviewing them. Hence before we jump into the main topic, I suggest you play around with Logic apps to see many outstanding features. My reaction to it until now has been none less than wow! You can do so many things using this Azure Service for SAP workloads.

Creating a Sample Logic Apps – Quick look for beginners!

Go to Azure Portal and enter the Logic Application pane to create your first workflow and click +Add. Fill the form with the app name, resource group, and location. Confirm by clicking Create. To build the Logic Apps, you can use one of the already existing templates on the dashboard. There are more than 40+ ready to deploy templates available and including the SAP Connector template too.

See below sample Architecture for Idoc flow from SAP to external documents. To run this similar scenario, you can refer to this article as well created by Bartosz Jarkowski

(Source: Microsoft)

This solution aims to facilitate a controlled shutdown/startup of SAP on Azure systems, a common request from customers who want to save costs by shutting down environments that are not in use, as I explained earlier. This custom scenario doesn’t have a predefined template, so I choose to create a Blank Logic App to build everything from scratch.

(Source: Microsoft)

Curtain-raiser on the Architecture side

Let’s understand the architecture workflow before we build and run the scenario, I would like to spend a moment to explain how the workflow will work here. Consider Logic App is a giant mothership controlling all flying saucers, aka. SAP, workflow, JSON/XML, Azure VMs, and required human intervention sitting on the ground (outlook) to decide the final action.

Ok, cool, so how does this map to the cloud flow? What tools required, uhh? Let’s see!

Source Gifer

List the prerequisites in order:

  • Access to Azure VM running SAP application
  • Access to SAP Application (ECC, S/4HANA, Netweaver)
  • Access to Azure Account with Subscription
  • An email account from a service that’s supported by Logic Apps (such as Office 365 Outlook or, other Email like Gmail supported as well. (I haven’t tested yet)


  1. Created Azure Logic App with Blank name
    SAP_Auto_mail_shut_Controller_App_amit <your-Logic-app-name>, then click on Azure Logic App Designer under the Development tools panel, as shown below.

2. Create a first HTTP trigger to run a Logic app

Search for workflow “request” and select “When a HTTP request is received“. And you will get an automated URL generated by workflow after you save the Logic apps. This URL can be triggered through the postman utility using POST or you can create a scheduler request with a specific time for trigger on a daily or weekly basis to trigger the Logic Apps at a specific time.

3. Setup an SAP Connection and select the SAP Table to fetch details. 

This step is crucial from a workflow perspective, here we going to connect SAP and fetch the list of active users logged in SAP during that point in time when workflow triggers.

  1. Click on + sign under HTTP Request, and search for SAP and select “Send a message to SAP”
  2. Click on the SAP Action folder icon and pickup RFC_READ_TABLE
  3. Insert XML details into “Input Message” shown below. We are fetching a list of users from SAP Table USR41.  Additionally, you can add the batch table to see active batches running in the system if required. (I’m just covering the user list for now!)
<RFC_READ_TABLE xmlns="http://Microsoft.LobServices.Sap/2007/03/Rfc/"> <QUERY_TABLE>USR41</QUERY_TABLE> </RFC_READ_TABLE>

SAP API Connection Details to fill, I did not activate SNC connection, SAP recommends to activate for production connectivity. (This the main internal combustion view)

Note, don’t proceed unless you see the successful connection here.

4. Data Operations – Compose stage

At this step search for “Data Operations” and select “Compose” as shown below.

Under compose, add Expression in fx


5. Parse JSON to fetch the relevant data using JSON schema

  1. Select Content – “Outputs” from the list
  2. Add JSON Schema using sample payload to generate the schema

You can generate JSON schema using as well.

6. Initialize the Variable and append it to an array variable. 

This task is part of initializing array and append array variable for loading data

Compose the output as well,


7. Setup the Outlook with options

User Options – YES – Shutdown, No -Shutdown, Add Subject and Body with {outputs}

8. Apply conditional check with the selected output from the previous Email

  • If the Email outcome is YES selected by an Admin/Basis user, then the logic app condition goes to the True side and follows the next workflow.
  • if the Email outcome is No selected by an Admin/Basis user, then logic apps will just check the status of the VM and close the loop.

9. SFTP-SSH workflow Action now 

Once the workflow is true, compose data operations workflows got the SelectedOption = Yes,

and we select the “SFTP-SSH” action workflow to create a new file under /tmp directory in SAP VM running and this will create a custom “python program” to stop/start and cleanup command simple script.

Please ensure, python3 is installed on SAP VM. (Link to download), I created this sap stop program in python 3.6 since it’s one of my favorite ones. Feel free to write in PowerShell or bash scripting, no restrictions here since the logic app flow will be the same at the end. In fact, you can change it to use sapcontrol tool as well since STOPSAP & STARTSAP are old tools now

10. Next workflow trigger delay, Delete and Power off VM

Since it required to 4-5min. to stop the SAP application and run the CLEANIPC command. Once Python shutdown SAP, that file will be automatically deleted from /tmp directory jus to safeguard accidental shutdown.
After SAP is down, another delay of a few min. (I took ~30min.) to trigger VM shutdown.
You can add confirmation Outlook after VM off and trigger Email notification back to Basis Manager for successful SAP and VM snoozing.

<**End of configuration, save your logic apps designer before you close the session**>

Time to Trigger the Button on Logic Apps 

Source: Gifer

Go and save your logic apps and press the Run button, before you do that please ensure SAP is up and running!

You will see Logic App, started here HTTP request and connected to SAP, and collected the data and parsed it for view. Now, Logic App triggers send Email on Outlook account and wait for next user action here.

I see a new Email in my Outlook mailbox now, Logic apps still waiting for the user action!

Open Email, and check the users logged actively, I see just one user at moment!
Now SAP Basis Operations can send an Email requesting that the user save the work and log out immediately or just simply go ahead with the shutdown, administrative call!

I’m pressing  => YES – Shutdown as shown below on Outlook Email.

It will popup the Logic App URL asking for a final decision here.
I pressed Confirm “YES-Shutdown” again. (You can disable that as well in the Email setting)

Thank you a confirmation screen below

Now going back to on workflow logic screen on Portal, it moves to the next level and creating a new python file that will help to shutdown SAP Application further.

Python file created successfully based on our Logic App design and SAP Shutdown triggered.
Well! No surprises and dancing moment!

At this stage, Logic App design flow, going to delete this python file, wait for VM Shutdown now.

After 30min. delay scheduler completed, VM Shutdown triggered successfully and VM is stopped.

Also, Azure Admin Team can check run history in Logic Apps on a daily/weekly basis for monitoring purposes, if required.


Okay Cool! That was quite the ride through some no-code process to trigger stop SAP and VM. and demonstrates how your SAP system using automation tools and Azure APIs altogether. I would suggest you go ahead and try this scenario and share your experience on SAP integration with Logic Apps, Especially on Dev, Training, and Sandbox systems that can be powered-off to save resources until they are needed again and highly recommended for pay-as-you-go customers.

Perhaps in the next article or so, I can provide you insights on how the SAP start functionality will work. It will be reverse Logic apps basically. I’m sure this will help to reduce the IT overheads linked to it, and that can be avoided for sure with this simple automation. You can consider it for your SAP systems running on Azure today or planning for future workloads.

Your questions/comments are always welcome!

💻💻💻Happy Reading, Happy Learning! 💻💻💻

Below links to my selective technical and personal insight articles published on SCN on various topics.
SAP Sales Forecast using Automated Machine Learning {Azure AutoML No-code}
Integrating SAP Data in Snowflake using Azure Data Factory
Running SAP HANA on Azure Container Instance {ACI} from Cloud shell 
The Three E-Elephants: EAI, ETL, and EII in Enterprise world
Power BI Vs. SAC – One-page reference

“Reading brings us unknown friends” – Honoré de Balzac

These are my personal opinions and thoughts. This does not represent any formal opinions, POVs, inputs, product road-maps, etc. from my current or past employers or partners or/and any Clients.