gpt4 book ai didi

azure - Powershell 中的 Set-AzureRmWebApp 更改未出现在 Azure 门户中

转载 作者:行者123 更新时间:2023-12-02 07:28:23 25 4
gpt4 key购买 nike

我正在尝试通过 Powershell 将虚拟应用程序添加到 Azure 网站。尽管脚本运行时没有错误,但我的更改不会出现在 Portal.azure.com 中。最后我需要运行另一个命令来保存更改吗?

$subscriptionId = "secret"
$websiteName = "MyWebsite"
$resourceGroupName = "MyResourceGroup"
$siteName = "Test"

Get-Module AzureRM
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId $subscriptionId
$website = Get-AzureRmWebApp -Name $websiteName -ResourceGroupName $resourceGroupName
$VDApp = New-Object Microsoft.Azure.Management.WebSites.Models.VirtualApplication
$VDApp.VirtualPath = "/$siteName"
$VDApp.PhysicalPath = "site\$siteName"
$VDApp.PreloadEnabled ="YES"
$website.siteconfig.VirtualApplications.Add($VDApp)
$website | Set-AzureRmWebApp -ResourceGroupName $resourceGroupName

最佳答案

尝试使用以下命令添加虚拟应用程序。

$resourceGroupName = ""
$websiteName = ""
$WebAppApiVersion = "2015-08-01"
# Example call: SetWebAppConfig MyResourceGroup MySite $ConfigObject
Function SetWebAppConfig($ResourceGroupName, $websiteName, $ConfigObject)
{
Set-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType Microsoft.Web/sites/Config -Name $websiteName/web -PropertyObject $ConfigObject -ApiVersion $WebAppApiVersion -Force
}
Write-Host "Set a virtual application"
$props=@{
virtualApplications = @(
@{ virtualPath = "/"; physicalPath = "site\wwwroot" },
@{ virtualPath = "/bar"; physicalPath = "site\wwwroot" }
)
}
SetWebAppConfig $ResourceGroupName $websiteName $props

我在实验室进行了测试,它对我有用。

enter image description here

有关此内容的更多信息,请参阅 herehere .

关于azure - Powershell 中的 Set-AzureRmWebApp 更改未出现在 Azure 门户中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45923540/

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