背景:
我正在尝试通过 Azure 上的 Runbooks 设置脚本。我发现不寻常的是,我可以通过 Azure Powershell Cloud Shell 运行命令并且它可以工作。但是,当我尝试通过 Runbook 运行它时,我收到一个错误(见下文)。
剧本:
$ResourceGroupName = "group"
$ServerName = "serverName"
$DatabaseName = "databaseName"
$StorageKeyType = "StorageAccessKey"
$StorageKey = "storageKey"
$StorageUri = "storageUri"
$AdminLogin = "admin"
$AdminPassword = (ConvertTo-SecureString "12345" -AsPlainText -Force)
New-AzureRmSqlDatabaseExport `
-AdministratorLogin $AdminLogin `
-AdministratorLoginPassword $AdminPassword `
-DatabaseName $DatabaseName `
-ResourceGroupName $ResourceGroupName `
-ServerName $ServerName `
-StorageKey $StorageKey `
-StorageKeyType $StorageKeyType `
-StorageUri $StorageUri `
**使用的通用值
错误:
New-AzureRmSqlDatabaseExport : No subscription found in the context. Please ensure that the credentials you provided
are authorized to access an Azure subscription, then run Connect-AzureRmAccount to login.
At line:10 char:1
+ New-AzureRmSqlDatabaseExport `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmSqlDatabaseExport], ApplicationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseExport
问题:
我究竟做错了什么?我使用的密码和用户名是在其他地方使用的密码和用户名,并且在我在 Cloud Shell 中运行脚本时工作。另外,“在上下文中找不到订阅”是什么意思?