我想使用Web Jobs重新启动我的应用程序服务。我已经编写了一个Power Shell脚本。使用服务原理连接到Azure的方法是返回空的订阅ID,订阅名称 下面是我的代码:
我尝试了下面的代码。当我手动连接时。整个过程都可以。但是我需要通过服务原理来实现
$azureAplicationId =""
$azureTenantId= ""
$azurePassword = ConvertTo-SecureString "password" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
Add-AzureRmAccount -Credential $psCred -TenantId $azureTenantId -ServicePrincipal
Restart-AzureRmWebApp -ResourceGroupName "devRG" -Name "draftfoxdatamanagementdev"
错误:
Account : Got details
SubscriptionName :
SubscriptionId :
TenantId : got details
Environment : got details
Restart-AzureRmWebApp : 'this.Client.SubscriptionId' cannot be null.
At C:\Users\tingu.marina.john\Documents\testingservice.ps1:6 char:1
+ Restart-AzureRmWebApp -ResourceGroupName "devRG" -Name "draftfoxdatam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Restart-AzureRmWebApp], ValidationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.WebApps.Cmdlets.WebApps.RestartAzureWebAppCmdlet