4
votes

Can I use my own/custom console application in Azure Runbook (PowerShell or any other)?

When I try to run my own console application (after retrieving it from Azure Storage), it fails.


When I try to execute it simply by:

.\myapp.exe

I get:

Program 'myapp.exe' failed to run: The operation was canceled by the user


When I use System.Diagnostics.Process:

$process = New-Object System.Diagnostics.Process
$process.StartInfo.FileName = $path
$process.StartInfo.UseShellExecute = $False
$process.Start()

I get a more meaningful error:

Exception calling "Start" with "0" argument(s): "This program is blocked by group policy. For more information, contact your system administrator"


Is there any settings in Azure Automation, I can toggle, to allow executing custom applications? Or is it simply not possible in the restricted Runbook environment?

3

3 Answers

3
votes

Thanks for reaching out! Unfortunately your ask of running .exe inside an Azure Automation runbook is currently not supported. And yes, you can go with Azure Web Job(s). One other customer has recently reached out with similar ask and solved their issue by leveraging Azure Web Job(s). For clarification, you may refer this MSDN thread. Hope this helps you.

Cheers!

2
votes

Unfortunately , it is not supported by Azure Automation Runbook for now.Here is a feedback replied by Automation PG team , there is no update on it.

2
votes

You can however

  1. Run console app as Azure WebJob on App Service and call it remotely via SCM endpoint or,
  2. Compile console application as PowerShell cmdlet

    using System.Management.Automation; 
    
    namespace MyApp
    {
      [Cmdlet(VerbsCommunications.Send, "RunApplication")]
      public class RunApplicationCommand : Cmdlet
      {
        protected override void ProcessRecord()
        {
          // App Code goes here
        }
      }
    }
    
    • Attach compiled DLL to PowerShell module
    • Deploy PowerShell modle to Automation account using Modules > Import
    • Call cmdlet from runbook