Azure

Begin a PowerShell Runbook by Webhook in Azure Automation Utilizing Energy Automate

Introduction

 

Azure Automation supplies a cloud-based automation and configuration service that gives constant administration throughout your Azure and non-Azure environments. Azure Automation helps to automate frequent, time-consuming, and error-prone cloud administration duties. It consists of course of automation, replace administration, and configuration options. 

 

Azure Automation lets you save time, cut back value & errors and improve effectivity. Consult with this hyperlink to be taught extra about pricing particulars.

 

Consult with my earlier article to discover ways to carry out the next actions:

  • Create an Automation Account
  • Create Credential Asset – To retailer the credentials which will probably be utilized by PowerShell for authentication.
  • Import PowerShell Module – Import Microsoft Groups PowerShell Cmdlets module with the intention to entry Groups Cmdlets.
  • Create PowerShell runbook – Script to create a brand new staff
  • Check and publish the runbook

On this article, you will note tips on how to provision a staff utilizing PowerShell runbook which will probably be known as by webhook from Energy Automate when customers submit the request within the SharePoint checklist.

 

A webhook permits an exterior service to start out a selected runbook in Azure Automation by way of a single HTTP request. Consult with this hyperlink to be taught extra in regards to the automation webhook.

 

Design Circulation

 

 

 

You will notice tips on how to carry out the next actions:

  • Create a SharePoint checklist – Customized checklist with default Title subject and it comprises the Staff title that must be created.
  • Create PowerShell runbook
  • Create a webhook
  • Create a stream in Energy Automate– It will get triggered when an merchandise is created in SharePoint checklist and name the HTTP motion.
  • Check the stream

Create a SharePoint checklist

  1. Navigate to SharePoint On-line web site.
  2. Create a customized checklist named as Microsoft Groups Requests.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

Create PowerShell runbook

 

Azure Automation helps a number of kinds of runbooks. Se are going to see how we will create the PowerShell runbook with the intention to provision a staff in Microsoft Groups.

 

Consult with this hyperlink to know extra about runbook sorts.
  1. Navigate to Automation account.
  2. Below Course of Automation, click on Runbooks.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Click on Create a runbook.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Enter the required particulars and click on

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Within the Edit pane, copy and paste the beneath script.
    1. Param  
    2. (  
    3.     [Parameter (Mandatory = $false)]  
    4.     [object] $WebhookData  
    5. )  
    6.  
    7. # If runbook was known as from Webhook, WebhookData will not be null.  
    8. if ($WebhookData) {  
    9.     # Gather properties of WebhookData  
    10.     $WebhookName = $WebHookData.WebhookName  
    11.     $WebhookHeaders = $WebHookData.RequestHeader  
    12.     $WebhookBody = $WebHookData.RequestBody  
    13.     $Enter = (ConvertFrom-Json -InputObject $WebhookBody)  
    14. }  
    15. else  
    16. {  
    17.     Write-Error -Message ‘Runbook was not began from Webhook’ -ErrorAction cease  
    18. }  
    19.  
    20. # Get the staff title from JSON enter  
    21. $teamName=$Enter.TeamName  
    22.  
    23. # Get the credential from Automation  
    24. $credential = Get-AutomationPSCredential -Title “TeamsAdminCredential”  
    25. $userName = $credential.UserName  
    26. $securePassword = $credential.Password  
    27.   
    28. $psCredential = New-Object –TypeName System.Administration.Automation.PSCredential –ArgumentList $userName, $securePassword  
    29.  
    30. # Join to Microsoft Groups  
    31. Join-MicrosoftTeams -Credential $psCredential  
    32.  
    33. # Create a new Staff  
    34. New-Staff -DisplayName $teamName  
    35.  
    36. # Disconnect from Microsoft Groups  
    37. Disconnect-MicrosoftTeams  
  1. Click on Save.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Publish the runbook.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Runbook efficiently printed, as proven beneath.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

Create a webhook

  1. Navigate to Automation account.
  2. Below Course of Automation, click on Runbooks.
  3. Click on the newly created runbook (named as CreateTeam).
  4. Click on Add webhook.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Click on Create new webhook. Enter the title and duplicate the URL (You would possibly be capable of see this as soon as the webhook has been created). Click on Okay.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Click on Parameters and run settings and click on Okay. Click on Create. Webhook created efficiently.

Create a stream in Energy Automate

  1. Navigate to the Energy Automate portal.
  2. Create a brand new stream and choose the set off as When an merchandise is created. Enter the title for the stream and click on Create.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Choose the positioning handle and checklist title for the set off, as proven beneath.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Add HTTP motion.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Enter the webhook URI which was copied whereas creating the webhook. Add the JSON to the Physique, as proven beneath.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Save the stream.

Check the stream

  1. Navigate to SharePoint On-line checklist. Create a brand new merchandise within the checklist.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Below Run historical past, you may see the final run and click on on it. Circulation ran efficiently, as proven beneath.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. HTTP Request:

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. From the physique, copy the Job Id which will probably be helpful in case if you have to discover the standing of the job.
  2. Navigate to Automation Account in Azure Portal.
  3. Below Course of Automation, click on Runbooks.
  4. Click on the newly created runbook (named as CreateTeam).
  5. Below Sources, click on Jobs and you’ll see the job standing. You may as well search the job based mostly on the Job Id which might be copied from the stream HTTP motion (Outputs -> Physique).

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. Click on on the job to see all of the required particulars.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

  1. The staff was created efficiently, as proven beneath.

    How To Start A PowerShell Runbook By A Webhook In Azure Automation Using Power Automate

Abstract

 

On this weblog, you noticed tips on how to begin a PowerShell runbook by a webhook in Azure Automation utilizing Energy Automate.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button