Challenge 6: SAP Start Stop Automation

< Previous Challenge - Home - Next Challenge >

Introduction

Contoso Inc is looking to optimize the cost of SAP landscape and exploring ways to do that. They’re leaning towards getting Reserves Instances (RI) for all production systems and would like to save cost on non-production (sandboxes, project systems, etc.) systems by not operating those during non-business hours. This solution helps them achieve that either using automation tools or schedule based

Description

The goal of this solution is to facilitate a controlled shutdown & startup of SAP systems, which is a common mechanism to save costs for non Reserved Instances (RI) VMs in Azure.

Note: VMs must be deallocated for Azure charges to stop and that’s facilitated by scripts

This flexible solution enables (using Azure automation, Azure Tags, Scripting, and PowerShell runbooks):

SAP systems start and stop is done gracefully (using SAP native commands), allowing SAP users and batch jobs to finish (with timeout) minimizing downtime impact. For detailed information refer below Architecture.

Architecture of the Start/Stop solution

The solution is using Azure automation account PaaS solution to execute the SAP shutdown/startup jobs (as shown in the below diagram). Runbooks are written in PowerShell. There is also a PowerShell module SAPAzurePowerShellModules that is used by all runbooks. These runbooks and module are stored in PowerShell Gallery, and are easy to import.

image

Information about SAP landscape and instances are to be stored in VM Tags.

Secure assets in Azure Automation include credentials, certificates, connections, and encrypted variables. These assets are encrypted and stored in Azure Automation using a unique key that is generated for each Automation account. Azure Automation stores the key in the system-managed Key Vault. Before storing a secure asset, Automation loads the key from Key Vault and then uses it to encrypt the asset.

SAP system start / stop / monitoring and SAP Application server Start / stop is implemented using scripts (calling SAP sapcontrol executable) via the Azure VM agent.

SAP HANA start / stop / monitoring is implemented using scripts (calling SAP sapcontrol executable) via the Azure VM agent.

SQL Server start / stop / monitoring is implemented using scripts (calling SAP Host Agent executable) via the Azure VM agent.

Azure runbooks can either be executed manually or scheduled.

Success Criteria

Learning Resources

Import Az.Modules

SAP start / stop PowerShell (PS) runbooks use new Az PS module, so import following AZ modules:

Import SAP PowerShell Module

Import SAPAzurePowerShellModules PowerShell module that will be used by SAP Runbooks.

NOTE: PowerShell module SAPAzurePowerShellModules is stored in PowerShell Gallery and is easy to import into Azure automation account.

Import SAP Runbooks

Navigate to Runbook Gallery and Import these runbooks:

NOTE: All SAP runbooks are stored in PowerShell Gallery and are easy to import into Azure automation account.

Tagging and executing Runbooks

Example Distributed SAP ABAP System with HANA – ALL Linux

Here is an example of a distributed SAP ABAP System TS1 with HANA DB. ALL VMs are Linux VMs. SAP HANA SID TS2 is different than SAP SID TS1.

image

HANA DB VM

DB has following properties.

Properties Value
VM Name ts2-db
Azure Resource Group Name gor-linux-eastus2
SAP System SID TS1

SAP HANA SID *

* in central SAP system HANA SID is can be different than SAP System SID

TS2
SAP HANA Instance Nr 0

VM [ts2-db] has to be tagged with following Tags:

Tag Value
SAPSystemSID TS1
SAPHANASID TS2
SAPDBMSType HANA
SAPHANAINstanceNumber 0

You can create these Tags manually. However, to simplify and automate Tagging process run this Azure runbook: Tag-SAPSystemStandaloneHANA

Parameter Mandatory Value
ResourceGroupName YES gor-linux-eastus2
VMName YES ts2-db
SAPSID YES TS1
SAPHANASID YES TS2
SAPHANAINstanceNumber YES 0

ASCS VM

ASCS has following properties.

Properties Value
Azure Resource Group Name gor-linux-eastus2
VM Name ts2-ascs
SAP System SID TS1
SAP ASCS Instance Nr 0

VM [ts2-ascs] has to be tagged with following Tags:

Tag Value
SAPSystemSID TS1
SAPApplicationInstanceType SAP_ASCS
SAPApplicationInstanceNumber 1

You can create these Tags manually. However, to simplify and automate Tagging process run this Azure runbook: Tag-SAPSystemASCSInstanceLinux

Parameter Mandatory Value
ResourceGroupName YES gor-linux-eastus2
VMName YES ts2-ascs
SAPSID YES TS1
SAPASCSInstanceNumber YES 1

SAP Application Server VM #1

SAP application server 1 has following properties.

Properties Value
Azure Resource Group Name gor-linux-eastus2
VM Name ts2-di0
SAP System SID TS1
SAP Dialog Instance Nr 1

VM [ts2-di0] has to be tagged with following Tags:

Tag Value
SAPSystemSID TS1
SAPApplicationInstanceType SAP_D
SAPApplicationInstanceNumber 1

You can create these Tags manually. However, to simplify and automate Tagging process run this Azure runbook: Tag-SAPSystemDialogInstanceLinux

Parameter Mandatory Value
ResourceGroupName YES gor-linux-eastus2
VMName YES ts2-ascs
SAPSID YES TS1
SAPDialogInstanceNumber YES 1

SAP Application Server VM #2

SAP application server 2 has following properties.

Properties Value
Azure Resource Group Name gor-linux-eastus2-2
VM Name ts2-di1
SAP System SID TS1
SAP Dialog Instance Nr 2

VM [ts2-di0] has to be tagged with following Tags:

Tag Value
SAPSystemSID TS1
SAPApplicationInstanceType SAP_D
SAPApplicationInstanceNumber 2

You can create these Tags manually. However, to simplify, avoid typos, and automate the tagging process use Azure runbook: Tag-SAPSystemDialogInstanceLinux

Parameter Mandatory Value
ResourceGroupName YES gor-linux-eastus2-2
VMName YES ts2-di1
SAPSID YES TS1
SAPDialogInstanceNumber YES 2

Runbook Description

Listing SAP System <SID> VMs: List-SAPSystemInstances

Parameter Mandatory Default value Comment
SAPSID YES    

Listing SAP HANA VM: List-SAPHANAInstance

Parameter Mandatory Default value Comment
SAPSID YES    

Start SAP System: Start-SAPSystem

Parameter Mandatory Default value Comment
SAPSID YES    
WaitForStartTimeInSeconds No 600 Wait time to start SAP system
ConvertDisksToPremium No $False If set to $True, all disk will be converted to Premium
PrintExecutionCommand No $False If set to $True, all OS commands will be printed

Runtime steps:

Stop SAP System: Stop-SAPSystem

Parameter Mandatory Default value Comment
SAPSID YES    
SoftShutdownTimeInSeconds No 600 Soft Shutdown time for SAP system
ConvertDisksToStandard No $False If set to $True, all disk will be converted to standard
PrintExecutionCommand No $False If set to $True, all OS commands will be printed

Runtime steps:

Start-SAPHANADB

This runbook will only start VM and standalone HANA DB.

Parameter Mandatory Default value
SAPHANASID YES  
ConvertDisksToPremium No $False
PrintExecutionCommand No $False

Runtime steps are:

Stop-SAPHANADB

This runbook will stop standalone HANA DB, and VM.

Parameter Mandatory Default value
SAPHANASID YES  
ConvertDisksToStandard No $False
PrintExecutionCommand No $False

Runtime steps:

Stop- SAPApplicationServer

This runbook will stop standalone SAP Application Server and VM.

Parameter Mandatory Default value
ResourceGroupName YES  
VMName YES  
SAPApplicationServerWaitTime No 300
ConvertDisksToStandard No $False
PrintExecutionCommand No $False

Runtime steps:

Start- SAPApplicationServer

This runbook will start VM and standalone SAP Application Server.

Parameter Mandatory Default value
ResourceGroupName YES  
VMName YES  
SAPApplicationServerWaitTime No 300
ConvertDisksToPremium No $False
PrintExecutionCommand No $False

Runtime steps: