【发布时间】:2021-04-13 04:13:39
【问题描述】:
大家下午好,
首先祝你在 2021 年乃至 2022 年一切顺利 这是我的问题,我正在等待我们的技术团队授予我访问 Azure Devops 平台的权限(这可能需要一段时间),但同时我想要一个临时解决方案,允许我部署 xmla(Json 格式)直接在现有的 SSAS 实例上,以便使用 powershell 创建多维数据集。
我已经阅读了一些文档,似乎最好的解决方案是使用 Invoke-ASCmd(如果我错了,请纠正我);而且我认为不可能通过 REST API 做到这一点
想法是以自动化的方式创建一个新的多维数据集
这是我的代码
$myfile = "c:\temp\test2.xmla"
$mybody=Get-Content -Path c:\temp\test2.xmla
$myaas="asazure://northeurope.asazure.windows.net/pocenvironment"
$myaasname="pocenvironment"
$mytenant = "1234"
$myclientID = "ABCD";
$mykeyID = "theKeyID";
$myauthority = "https://login.windows.net/" + $mytenant + "/oauth2/authorize";
$TokenRequestParams = @{
Method = 'POST'
Uri = "$myauthority"
Body = @{
grant_type = "urn:ietf:params:oauth:grant-type:device_code"
code = $DeviceCodeRequest.device_code
client_id = $myclientID
}
}
$TokenRequest = Invoke-RestMethod @TokenRequestParams
$myconnectstr="Provider=MSOLAP;User ID=;Password="+$TokenRequest+";Data Source="+$myaas+";Persist Security Info=True;Impersonation Level=Impersonate"
Invoke-ASCmd -InputFile $myfile -ConnectionString $myconnectstr -Server $myaas
XMLA 是这样的
{
"create": {
"database": {
"name": "TESTME",
"compatibilityLevel": 1500,
"model": {
"culture": "en-GB",
"dataSources": [
],
"tables": [
],
"relationships": [
],
"roles": [
{
"name": "Admin",
"modelPermission": "administrator",
"members": [
{
"memberName": "myemail@domain.com",
"identityProvider": "AzureAD"
}
]
},
{
"name": "Reader",
"modelPermission": "read",
"members": [
]
}
],
"annotations": [
{
"name": "ClientCompatibilityLevel",
"value": "400"
}
]
}
}
}
}
但我收到以下错误消息(尝试使用 powershell ise x86 和 64 位)
<b>Invoke-ASCmd : Object reference not set to an instance of an object.
At line:24 char:1
+ Invoke-ASCmd -InputFile $myfile -ConnectionString $myconnectstr -Serv ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Invoke-ASCmd], NullReferenceE
xception
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.Analysis
Services.PowerShell.Cmdlets.ExecuteScriptCommand
</b>
【问题讨论】:
标签: azure powershell automation ssas