【发布时间】:2018-06-14 11:31:01
【问题描述】:
I am using and edited version of the script in the first answer on this question。我首先登录,选择适当的订阅,然后获取 Azure Rm 上下文。执行此操作时出现此错误:
Get-AzureWebsiteJob :未指定默认订阅。使用 Select-AzureSubscription -Default 设置默认订阅。
脚本:
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId subidguid
Get-AzureRmContext
$groups = get-AzureRmResourceGroup
foreach($group in $groups){
$webApps = Get-AzureRmWebApp -ResourceGroupName $group.ResourceGroupName
foreach($webApp in $webApps){
write-host -ForegroundColor Yellow $webApp.Name
### ERROR HAPPENS
$job = Get-AzureWebsiteJob -Name $webApp.Name
if($job){
write-host -ForegroundColor DarkYellow $job.JobName
}
$job = Get-AzureWebsiteJob -Name $webApp.Name -Slot staging
if($job){
write-host -ForegroundColor DarkYellow $job.JobName " -staging"
}
}
}
我确实得到了屏幕上输出的网络应用程序的名称,但是当它查找网络作业时,我得到了那个错误。我根据错误尝试了以下技术,但这没有帮助(编辑了完整的代码以明确我做了哪些更改,即使我仍然遇到相同的错误):
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId subidguid
Get-AzureRmContext
$groups = get-AzureRmResourceGroup
foreach($group in $groups){
$webApps = Get-AzureRmWebApp -ResourceGroupName $group.ResourceGroupName
foreach($webApp in $webApps){
write-host -ForegroundColor Yellow $webApp.Name
### ERROR HAPPENS
Select-AzureRmSubscription -SubscriptionId subidguid
$job = Get-AzureWebsiteJob -Name $webApp.Name
if($job){
write-host -ForegroundColor DarkYellow $job.JobName
}
### ERROR HAPPENS
Select-AzureRmSubscription -SubscriptionId subidguid
$job = Get-AzureWebsiteJob -Name $webApp.Name -Slot staging
if($job){
write-host -ForegroundColor DarkYellow $job.JobName " -staging"
}
}
}
基本上,在获取网络作业详细信息之前,我首先选择订阅 ID(缩短):
Select-AzureRmSubscription -SubscriptionId subidguid
$job = Get-AzureWebsiteJob -Name $webApp.Name
正在执行...
选择-AzureRmSubscription -Default -SubscriptionId subguidid
引发不同的错误:
Set-AzureRmContext : 缺少参数的参数 '默认配置文件'。指定类型的参数 'Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer' 然后再试一次。
我尝试使用DefaultProfile 参数而不是Default。无论我使用Default 传递什么,我都会收到错误:
Set-AzureRmContext:无法绑定参数“DefaultProfile”。不能 将“System.String”类型的“WhatYouEntered”值转换为类型 “Microsoft.Azure.Commands.Common.Authentication.Abstractions.IAzureContextContainer”。
我仍然遇到同样的错误。当我查看Get-AzureWebsiteJob 函数中允许的参数时,我没有看到指定订阅的选项。既然职位应该通过网络应用搜索,并且网络应用返回,为什么这里没有通过订阅 id 找到它?
【问题讨论】:
标签: powershell azure azure-web-app-service azure-webjobs