我正在尝试通过 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
我在实验室进行了测试,它对我有用。
关于azure - Powershell 中的 Set-AzureRmWebApp 更改未出现在 Azure 门户中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45923540/