Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Powershell Workflow - Input Parameters Not Found

Background

I have a workflow defined using a straightforward template from within Azure.

workflow Use-SqlCommandSample
{
param(
    [parameter(Mandatory=$True)]
    [string] $SqlServer,

    [parameter(Mandatory=$False)]
    [int] $SqlServerPort = 1433,

    [parameter(Mandatory=$True)]
    [string] $Database,

    [parameter(Mandatory=$True)]
    [string] $Table,

    [parameter(Mandatory=$True)]
    [PSCredential] $SqlCredential
)

# Get the username and password from the SQL Credential
$SqlUsername = $SqlCredential.UserName
$SqlPass = $SqlCredential.GetNetworkCredential().Password

inlinescript {
    # Define the connection to the SQL Database
    $Conn = New-Object System.Data.SqlClient.SqlConnection("Server=tcp:$using:SqlServer,$using:SqlServerPort;Database=$using:Database;User ID=$using:SqlUsername;Password=$using:SqlPass;Trusted_Connection=False;Encrypt=True;Connection Timeout=30;")

    # Open the SQL connection
    $Conn.Open()

    # Define the SQL command to run. In this case we are getting the number of rows in the table
    $Cmd=new-object system.Data.SqlClient.SqlCommand("SELECT COUNT(*) from dbo.$using:Table", $Conn)
    $Cmd.CommandTimeout=120

    # Execute the SQL command
    $Ds=New-Object system.Data.DataSet
    $Da=New-Object system.Data.SqlClient.SqlDataAdapter($Cmd)
    [void]$Da.fill($Ds)

    # Output the count
    $Ds.Tables.Column1

    # Close the SQL connection
    $Conn.Close()
}
}

Issue

When I go to either test the workflow or run it, I'm not prompting for any input parameters. No input parameters

like image 260
Nick Heidke Avatar asked May 12 '17 19:05

Nick Heidke


People also ask

What is PowerShell workflow?

A Windows PowerShell Workflow is a Windows PowerShell script that leverages Windows Workflow Foundation. While the workflow is written with Windows PowerShell syntax and launched by Windows PowerShell, it is processed by Windows Workflow Foundation.

How do you call a runbook from another runbook?

To invoke a runbook inline from another runbook, you use the name of the runbook and provide values for its parameters exactly like you would use an activity or cmdlet.

What is a azure runbook?

PowerShell Workflow runbooks are text runbooks based on Windows PowerShell Workflow. You directly edit the code of the runbook using the text editor in the Azure portal. You can also use any offline text editor and import the runbook into Azure Automation.


1 Answers

Try putting your parameters at the top like this. Works for my runbooks.

param(
    [parameter(Mandatory=$True)]
    [string] $SqlServer,

    [parameter(Mandatory=$False)]
    [int] $SqlServerPort = 1433,

    [parameter(Mandatory=$True)]
    [string] $Database,

    [parameter(Mandatory=$True)]
    [string] $Table,

    [parameter(Mandatory=$True)]
    [PSCredential] $SqlCredential
)

workflow Use-SqlCommandSample
{
    # Get the username and password from the SQL Credential
    $SqlUsername = $SqlCredential.UserName
    $SqlPass = $SqlCredential.GetNetworkCredential().Password
    ...
}
like image 198
Zucchini Avatar answered Nov 15 '22 05:11

Zucchini