Reputation: 1920
What are the options to authenticate the powershell azure management cmdlets like New-AzureSqlDatabaseServer
and New-AzureSqlDatabase
?
It looks like New-AzureSqlDatabaseServer
needs the administrator's user name and password explicitly passed whereas New-AzureSqlDatabase
needs to know the context (Context can be created using Get-Credential
cmdlet or by manually creating an object of type PSCredential
by passing plain text password)
Wondering if there are other ways to authenticate these management cmdlets without passing/prompting for the admin user name or password? I am looking for something in the lines of publish settings certificate that could be imported once to the deployment servers.
Background - I am looking to automate the SQL azure server and database creation using powershell and trying to do this without having to prompt/pass admin password
Upvotes: 1
Views: 1537
Reputation: 182
I was looking for the same thing and I found a trick to get it...
$cred=Get-Credential
$userName=$cred.UserName
$password=$cred.GetNetworkCredential().Password
New-AzureSqlDatabaseServer -Version "12.0" -AdministratorLogin $userName -AdministratorLoginPassword $password -Location "West US"
Reference: Decrypt PowerShell Secure String Password
Upvotes: 0
Reputation: 441
So, New-AzureSqlDatabaseServer
uses your subscription credentials. You can currently create a context for use with New-AzureSqlDatabase
using a PSCredential
, which you can create by instantiating a SecureString
for the password - the ConvertTo-SecureString
commandlet can help with this.
Upvotes: 1