【发布时间】:2016-01-11 14:53:28
【问题描述】:
我正在使用 PowerShell 备份 Azure SQL 数据库。运行良好的脚本的最后一部分是:
Write-Output "Exporting databases"
foreach ($db in $azSqlServerDatabases) {
$exportRequest = Start-AzureSqlDatabaseExport -SqlConnectionContext $azSqlStageConnContext -StorageContainer $container -DatabaseName $db.Name -BlobName ($db.Name + ".bacpac")
$exportRequests.Add($exportRequest)
Write-Output ($db.Name + ".bacpac")
}
我正在尝试创建通用列表:
$exportRequests = New-Object 'System.Collections.Generic.List[Microsoft.WindowsAzure.Commands.SqlDatabase.Services.ImportExportRequest]'
其中必须保存请求的结果。问题是当我创建通用列表时出现错误:
New-Object : Cannot find type [System.Collections.Generic.List[Microsoft.WindowsAzure.Commands.SqlDatabase.Services.ImportExportRequest]]: verify that the assembly containing this type is lo
aded.
At C:...
+ ... tRequests = New-Object 'System.Collections.Generic.List[Microsoft.Win ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
我在哪里可以找到这种类型?为什么不包含它 - 我成功调用 Start-AzureSqlDatabaseExport 并且我得到了结果对象 - 所以类型是已知的。
尝试在 Azure PowerShell 控制台中手动创建一个类型的对象会引发相同的异常:
PS C:\> $x = new-object 'Microsoft.WindowsAzure.Commands.SqlDatabase.Services.ImportExportRequest'
new-object : Cannot find type [Microsoft.WindowsAzure.Commands.SqlDatabase.Services.ImportExportRequest]: verify that t
he assembly containing this type is loaded.
At line:1 char:6
+ $x = new-object 'Microsoft.WindowsAzure.Commands.SqlDatabase.Services ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
+ FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
PS C:\>
我从MS documentation.得到了输出类型
【问题讨论】:
标签: azure azure-sql-database azure-powershell