Invoke-ASCmd:身份验证失败:当用户界面不可用时,需要用户ID和密码 [英] Invoke-ASCmd : Authentication failed: User ID and Password are required when user interface is not available

查看:177
本文介绍了Invoke-ASCmd:身份验证失败:当用户界面不可用时,需要用户ID和密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Azure DevOps通过CICD刷新(已)部署的表格模型的凭据.在PowerShell中使用 Invoke-ASCmd 刷新凭据.当我提供租户ID,应用程序ID和密钥时,该脚本在本地运行良好.但是,当我从Azure Devops运行它时,它失败并出现错误-当用户界面不可用时,需要用户ID和密码.这是脚本:

I am trying to refresh credentials of an (already)deployed Tabular Model via CICD using Azure DevOps. Making use of Invoke-ASCmd in PowerShell to refresh the credentials. The script works fine from local when I provide the Tenant ID, App ID and the Key. However it fails when I run it from Azure Devops with error - User ID and Password are required when user interface is not available. Here is the script:

$azureTenantId= "TenantId"
$azurePassword = ConvertTo-SecureString "Key" -AsPlainText -Force
$azureAplicationId ="AppID"

$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
Connect-AzAccount -Credential $psCred -TenantId $azureTenantId  -ServicePrincipal 

Invoke-ASCmd `
    -Server "AnalysisServerName" `
    -Database "AdventureWorks" `
    -Query "{
  ""createOrReplace"": {
    ""object"": {
      ""database"": ""AdventureWorks"",
      ""dataSource"": ""AzureBlobs/https://abc blob core windows net/""
    },
    ""dataSource"": {
      ""type"": ""structured"",
      ""name"": ""AzureBlobs/https://abc blob core windows net/"",
      ""connectionDetails"": {
        ""protocol"": ""azure-blobs"",
        ""address"": {
          ""account"": ""abc"",
          ""domain"": ""blob.core.windows.net""
        },
        ""authentication"": null,
        ""query"": null
      },
      ""credential"": {
        ""AuthenticationKind"": ""Key"",
        ""kind"": ""AzureBlobs"",
        ""path"": ""https://abc.blob.core.windows.net/"",
        ""PrivacySetting"": ""Organizational"",
        ""Key"": ""Key""
      }
    }
  }
}" 

推荐答案

Import-Module Azure.AnalysisServices
$azureappid ="tesappid"
$azureTenantId= "testid"

[ValidateNotNullOrEmpty()] $userPassword = "testpwd"

$userPassword = ConvertTo-SecureString -String $userPassword -AsPlainText -Force
$userCredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $azureappid, $userPassword
    
Add-AzureAnalysisServicesAccount -RolloutEnvironment 'eastus.asazure.windows.net' -Credential $userCredential -TenantId $azureTenantId  -ServicePrincipal 

Invoke-Ascmd ....

这篇关于Invoke-ASCmd:身份验证失败:当用户界面不可用时,需要用户ID和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆