stop/start AlwaysOn Cluster via Azure Automation

KM 1 Reputation point
2021-09-24T18:07:59.42+00:00

I am working on a start/stop of an alwaysOn cluster using an azure automation account. I can't seem to load the failoverclusters module into the automation account to utilize stop-cluster/start-cluster so I'm working on getting a runbook to call a stored PS script, but it seems there should be an easier way.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,113 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,364 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. tbgangav-MSFT 10,381 Reputation points
    2021-09-26T06:45:21.973+00:00

    Hi @KM ,

    If you meant this module then I would recommend to try importing the module to Azure Automation account as explained here. Or else if you are looking for a way to call a PS script from a runbook then you can follow one of the below 3 approaches:

    1. Hybrid runbook worker i.e., Runbooks in Azure Automation might not have access to resources in other clouds or in your on-premises environment because they run on the Azure cloud platform. You can use the Hybrid Runbook Worker feature of Azure Automation to run runbooks directly on the machine that's hosting the role and against resources in the environment to manage those local resources. Runbooks are stored and managed in Azure Automation and then delivered to one or more assigned machines.
    2. Create an Azure storage account, container and upload a blob i.e., script (say xxxxxxxxxxxx.ps1 file with the content of your script) and then have below code in Azure Automation PowerShell runbook.
    3. Save a script (say xxxxxxxxxxxxxx.ps1) in your local machine (from where it executed without any issues) and have your script as content in that file and then have below code in Azure Automation PowerShell runbook.

    For more information with regards to above mentioned 3 approaches, refer answer in this question.

    If your use case or scenario is different and if you are looking for something else then please let me know with little more context.

    0 comments No comments

  2. Limitless Technology 39,356 Reputation points
    2021-09-27T14:05:37.417+00:00

    Hello KM,

    You should avoid using variables in the Name parameter of Get-AutomationPSCredential. Their use can complicate the discovery of dependencies between runbooks or DSC configurations and credential assets at design time.

    Check out the below link for cmdlets

    https://learn.microsoft.com/en-us/azure/automation/shared-resources/credentials?tabs=azure-powershell

    A similar topic is discussed in the below link, do have a look at it for better understanding.

    https://learn.microsoft.com/en-us/answers/questions/277798/azure-automation-account-and-sql-server-vm.html

    ---------------------------------------------------------------------------------------------------

    Hope this answers all your queries, if not please do repost back.
    If an Answer is helpful, please click "Accept Answer" and upvote it : )

    0 comments No comments