1
votes

There are several Runbooks examples in the Azure Runbook Gallery, such as:

  • Deploy a Windows Azure Web Site Pointing to a SQL Database and Storage Account

that use the following syntax with Get-Credential:

$credential = Get-Credential

which implies that the command should prompt for the credentials -- but this fails in a Runbook with the following message:

Get-Credential : Cannot process command because of one or more missing mandatory parameters: Credential.

The credentials that are desired here are for this purpose:

# Get credentials from user to setup administrator access to new SQL Azure Server

which then should get used in downstream cmdlet calls in the Runbook such as

$databaseServer = New-AzureSqlDatabaseServer -AdministratorLogin $credential.UserName `
    -AdministratorLoginPassword $credential.GetNetworkCredential().Password -Location $Location

But because Get-Credential fails the downstream calls fail.

What I am doing wrong?

Why does a Runbook in the Gallery have statements that seem to be incompatible (prompt for Credentials) with allowable Runbook behaviors?

1

1 Answers

2
votes

So with Azure Automation, you would create a credential asset (for example, named AzureAdmin) and then you would reference that in the runbook, to get those credentials:

$cred = Get-AutomationPSCredential -Name AzureAdmin

As for the reference script, I suppose, it was just added to the runbook gallery without any verification, so in reality its not Azure Automation friendly