Search code examples
powershellazurepowershell-iseazure-automationpowershell-module

Azure Automation Module Import - How to investigate module members not being exported/extracted as Activities?


I have a custom module with some embedded Workflow & Native ps1 cmdlets.

When I import this module, only a subset of the cmdlets are showing up as extracted Activities under the Module.

The module is completing the import successfully, and shows as Available.

Is there anywhere to look to find the specific output and any possible member-specific import errors?

The cmdlets which are failing to load are dependent upon some new types added as part of an assembly. The cmdlets which are loading are also dependent on types from that assembly.

Adding to the confusion, when I import this module locally in ISE, everything works fine and all the cmdlets are available/executable.

Further: I've seen this with Native PowerShell cmdlets, but it also appears as though (single) PowerShell Workflow activity inside a .ps1 is not supported.

In addition, I've seen that locally, depending on whether or not a load my module using the .psd1 or the .psm1, I get different behavior & results WRT dependent assembly loading.

In particular, when trying to troubleshoot the inconsistencies locally, I've gotten a number of "can't find type" or "found more than one overload for ctor with 1 arg" (despite the type in question not having a ctor with 1 arg) errors with types referenced via [OutputType([typename])], etc, when OTHER cmdlets that DO rely on types from the SAME assembly are found just fine..

[EDIT]
local verbose output from my testing .psm1

VERBOSE: Importing function 'sync-test'.
VERBOSE: Importing command as workflow 'Sync-VsoGitRmRunbook'.

In AA, sync-test (just a plain runbook that writes string output) is showing up fine, while Sync-VsoGitRmRunbook does not.

If I convert sync-test to a workflow, it also stops importing, leading me to believe that there is a limitation with modules exporting Workflow activities that are bundled as .ps1 files (as opposed to being C# classes packaged in the module)

[EDIT]
I've created a module that reproduces the problem. https://github.com/JoeBrockhaus/AzureAutomationVsoGitSync


Solution

  • Only PowerShell cmdlets / DSC resources can be imported into Azure Automation through PowerShell modules. If you convert your Workflow activities to cmdlets, import should succeed.

    You probably want these Workflow activities to be cmdlets anyway, so they can be leveraged in non PowerShell Workflow runbooks as well.