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

标签 azure azure-web-app-service azure-powershell

我正在尝试通过 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/

相关文章:

azure - Azure 点到站点客户端能否看到默认的 Azure DNS?

reactjs - 如何将 React 应用程序从 GitHub 部署到 Azure 应用服务

visual-studio - 将 TFSService 版本发布到 Azure 失败并出现 DirectoryNotFoundException

azure - 使用 Symfony 的 Microsoft Azure 应用服务的性能问题

powershell - 通过 PowerShell 启用对 HDInsight 群集的 RDP 访问

mysql命令行连接到azure

azure - 无法从 Kubernetes 获取 apiVersions : Unable to retrieve the complete list of server APIs

azure - 如何在 Azure 文件共享目录中设置目录元数据

powershell - Powershell : Run Login-AzureRmAccount to login

c# - 将图像列表发送到 azure 函数以将图像上传到 .Net 中的 blob