我已安排一个 PowerShell 脚本来执行 Azure 中的管道。 已使用 Login-AzureRMAccount 生成登录脚本(ProfileContext.ctx)
下面是要安排的代码:
$path = "D:\ProfileContext.ctx"
Import-AzureRmContext -Path $path
$dfn = "salesprod"
$rgn = "sale-dw"
$df=Get-AzureRmDataFactory -ResourceGroupName $rgn -Name $dfn
$ISTstartdate = get-date
#Set Pipeline active period
$UTCstartdate = $ISTstartdate.touniversaltime().addminutes(5)
$UTCenddt = $UTCstartdate.AddHours(5)
$pipelinename = "SalesPipeline"
Set-AzureRmDataFactoryPipelineActivePeriod -ResourceGroupName $rgn -PipelineName $pipelinename -DataFactoryName $dfn -StartDateTime $UTCstartdate -EndDateTime $UTCenddt -Force
上面的代码可以正常工作 2 或 3 天,但随后我开始遇到以下问题:
您的 Azure 凭据尚未设置或已过期,请运行 Login-AzureRMAccount 来设置您的 Azure 凭据。 在 D:\RunPipeline.ps1 以下是版本号:
- PS 版本 - 5.0.10586.117
- Azure - 4.2.1
最佳答案
我通过使用以下解决方法解决了这个问题:这将为我自动登录,然后我可以在没有上下文文件的情况下进行安排:
$accountName = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5b2b2a291b23222175383436" rel="noreferrer noopener nofollow">[email protected]</a>"
$password = ConvertTo-SecureString "mypwd" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($accountName, $password)
Login-AzureRmAccount -Credential $credential
Get-AzureRmResource
关于powershell - Azure 凭据尚未设置或已过期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46089692/