I want to get the Azure runbook name within the environment sandbox of the runbook.
Is it possible to do that? Like, are there any predefined variables that we can get as in the case of Azure Pipelines?
I have checked a bit the documentation but I couldn't find anything related.
AFAIK there is no predefined variables that you can use in automation to get the variable. After a workaround on this, I found a couple of approaches which are listed below.
Approach-1:
Using
Get-AzAutomationVariableto retrieve the predefined variables by storing it invariablesundershared resourcesof automation account blade as shown.Note: If you want to execute it in azure runbook, perform the same script and it will work as expected.
Approach-2:
Another one is using
Start-AzAutomationRunbook. With this command, you can access the runbook by passing runbook name as aparameterin the automation script as given below.