Powershell中的Set-AzureRmWebApp更改未出现在Azure门户中 [英] Set-AzureRmWebApp changes in Powershell not appearing in Azure Portal

查看:126
本文介绍了Powershell中的Set-AzureRmWebApp更改未出现在Azure门户中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am trying to add a virtual application to an Azure website via Powershell. Though the script runs without errors, my changes don't appear in portal.azure.com. Is there another command I need to run at the end to persist the changes?

$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

推荐答案

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

Try to use the following commands to add a virtual application.

$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

我在实验室测试,对我有用.

I test in my lab, it works for me.

有关此的更多信息,请参见此处此处.

More information about this, see here and here.

这篇关于Powershell中的Set-AzureRmWebApp更改未出现在Azure门户中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆