Install Kubectl in azure automation account

NK, SatishKumar 71 Reputation points
2023-05-30T13:56:09.57+00:00

How do i install kubectl module in azure automation account and use it. Any examples would be helpfull

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,188 questions
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,421 Reputation points
    2023-06-04T16:07:01.63+00:00

    Hi @NK, SatishKumar ,

    As explained in this Azure document, runbooks that run in Azure sandboxes don't support calling processes, such as executables (.exe files like kubectl) or subprocesses. The reason for this is that an Azure sandbox is a shared process run in a container that might not be able to access all the underlying APIs. For scenarios requiring third-party software or calls to subprocesses, you should execute a runbook on a Hybrid Runbook Worker. So, you may try to use the Hybrid Runbook Worker feature of Azure Automation to run runbooks calling kubectl directly on the machine hosting it 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.

    Or as suggested by @Konstantinos Passadis , you may use module's like Microsoft.PowerShell.KubeCtl but if you go with them then you might not be able to directly use kubectl command in your runbook running in Azure sandbox but you might have to use the PowerShell cmdlet's provided by the module. Please check below screenshots to find all such kubectl related PowerShell Azure Automation modules and also what are the PowerShell cmdlets supported by Microsoft.PowerShell.KubeCtl and how to use them.

    User's image

    User's image

    User's image

    User's image