简体   繁体   中英

Credentials for Powershell Azure management cmdlets

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM