gpt4 book ai didi

azure - Get-AzWebApp : The term 'Get-AzWebApp' is not recognized as the name of a cmdlet, 函数 - Azure Devops

转载 作者:行者123 更新时间:2023-12-03 06:49:00 28 4
gpt4 key购买 nike

我正在尝试通过 azure devops pipeline() 在 PowerShell 脚本下运行,以将新的专用终结点添加到我的 azure Vnet。不幸的是我遇到了以下错误。

错误:Get-AzWebApp:术语“Get-AzWebApp”未被识别为 cmdlet、函数、脚本文件或可操作的名称程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试

azure-pipelines.yml

#Starter pipeline
#Start with a minimal pipeline that you can customize to build and deploy your code.
#Add steps that build, run tests, deploy, and more:
#https://aka.ms/yaml

trigger:
- main

pool:
vmImage: 'windows-latest'

steps:
- task: AzureCLI@2
inputs:
azureSubscription: 'Azure subscription 1(XXXXXX)'
scriptType: 'ps'
scriptLocation: 'scriptPath'
scriptPath: 'PrivateEndpointTest.ps1'

PrivateEndpointTest.ps1

$webapp = Get-AzWebApp -ResourceGroupName ENDPOINTTEST -Name anuendpointtest


## Create the private endpoint connection. ##
$pec = @{
Name = 'myConnection'
PrivateLinkServiceId = $webapp.ID
GroupID = 'sites'
}
$privateEndpointConnection = New-AzPrivateLinkServiceConnection @pec

## Place the virtual network you created previously into a variable. ##
$vnet = Get-AzVirtualNetwork -ResourceGroupName 'ENDPOINTTEST' -Name 'VNET_ENDPOINT_TEST'

## Create the private endpoint. ##
$pe = @{
ResourceGroupName = 'VNET_ENDPOINT_TEST'
Name = 'myPrivateEndpoint'
Location = 'North Europe'
Subnet = $vnet.Subnets[0]
PrivateLinkServiceConnection = $privateEndpointConnection
}
New-AzPrivateEndpoint @pe

最佳答案

请尝试Azure PowerShell 任务并选择最新版本。

Azure CLI 需要以管理员身份运行以下命令:

Install-Module Az 

Import-Module Az

如果要使用 Azure CLI,请考虑使用自托管代理。

Similar thread供您引用。

关于azure - Get-AzWebApp : The term 'Get-AzWebApp' is not recognized as the name of a cmdlet, 函数 - Azure Devops,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73880267/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com