Having a problem with creating an azure automation runbook that will copy a database on demand; I've created a credential and stored the u/p of the account I use to log into the portal in it. Password was written in notepad and pasted in to ensure correct.
$Cred = Get-AutomationPSCredential -Name 'automationCredential'
Write-Output "UN: $($Cred.Username)"
Write-Output "PW: $($Cred.Password.Length)"
Add-AzureRmAccount -Credential $Cred
Write-Output "Deleting the old $TargetDatabaseName"
Remove-AzureRMSqlDatabase -ResourceGroupName "Default-SQL-NorthEurope" -ServerName $SourceServerName -DatabaseName $TargetDatabaseName -Force
Write-Output "Creating new $TargetDatabaseName with data at time $PointInTime"
New-AzureRmSqlDatabaseCopy `
-CopyDatabaseName $TargetDatabaseName `
-DatabaseName $SourceDatabaseName `
-ResourceGroupName "Default-SQL-NorthEurope" `
-ServerName $SourceServerName
The debug prints seem to indicate the credentials are correct, but when the add-azurermaccount is carried out, it seems to log in but no subscriptions are returned
Soon after the call to remove the old test db fails with:
Remove-AzureRMSqlDatabase : No subscription found in the context. Please ensure that the credentials you provided are authorized to access an Azure subscription, then run Login-AzureRMAccount to login.
If I do the actions in the command line powershell (the only difference being I call login without parameters; it prompts for creds) then things work out just fine
I found some resources that indicate if the creds are wrong, it authenticates but returns no subscriptions - i've double checked the creds tho and they're accurate