azure webapp 您无权查看此目录或页面

azure webapp You do not have permission to view this directory or page

您好,我有一个使用 terraform 创建的简单 Web 应用程序,配置了 vnet 区域集成:

resource "azurerm_app_service" "app-indigo" {
  name                = "app-${var.environment}-${var.app_name}"
  location            = data.azurerm_resource_group.rg.location
  resource_group_name = data.azurerm_resource_group.rg.name
  app_service_plan_id = azurerm_app_service_plan.app-plan.id
  

  site_config {
    dotnet_framework_version = "v4.0"
  } 

resource "azurerm_app_service_virtual_network_swift_connection" "app-indigo-swift" {
  app_service_id = azurerm_app_service.app-app.id
  subnet_id      = data.azurerm_subnet.subnet["integration"].id
}

无论我如何尝试从内部网络或应用程序网关访问 Web 应用程序,我都会得到以下信息

You do not have permission to view this directory or page.

这是默认的网络应用程序,尚未部署代码,非常感谢您的帮助

此错误可能发生在您的 wwwroot 文件夹中缺少 Web.config 文件。如果您省略 site_config,Terraform 将调用 Azure API 来创建默认网站。此错误将消失。

所以你可以使用这样的代码:

resource "azurerm_app_service" "app-indigo" {
      name                = "app-${var.environment}-${var.app_name}"
      location            = data.azurerm_resource_group.rg.location
      resource_group_name = data.azurerm_resource_group.rg.name
      app_service_plan_id = azurerm_app_service_plan.app-plan.id         
} 

或者,您可以部署包含 Web 内容的网站。例如,您可以创建 an ASP.NET Framework web app in Azure.

The example provisions a Windows App Service. Other examples of the azurerm_app_service resource can be found in the ./examples/app-service directory within the Github Repository.