Nay*_*Van 2 azure-virtual-network terraform-provider-azure
我正在尝试自动部署 azure 虚拟网络和 azure Web 应用程序。在部署这些资源的过程中,一切都很顺利,没有出现任何错误。所以我想尝试激活private endpoint网络应用程序。这是我在 terraform 上的配置。
resource "azurerm_virtual_network" "demo-vnet" {
name = "virtual-network-test"
address_space = ["10.100.0.0/16"]
location = var.location
resource_group_name = azurerm_resource_group.rg-testing-env.name
}
resource "azurerm_subnet" "front_end" {
name = "Front_End-Subnet"
address_prefixes = ["10.100.5.0/28"]
virtual_network_name = azurerm_virtual_network.demo-vnet.name
resource_group_name = azurerm_resource_group.rg-testing-env.name
delegation {
name = "testing-frontend"
service_delegation {
name = "Microsoft.Web/serverFarms"
actions = ["Microsoft.Network/virtualNetworks/subnets/action"]
}
}
}
Run Code Online (Sandbox Code Playgroud)
在网络应用程序本身上,我设置了此配置
resource "azurerm_app_service_virtual_network_swift_connection" "web-app-vnet" {
app_service_id = azurerm_app_service.app-test.example.id
subnet_id = azurerm_subnet.front_end.id
}
Run Code Online (Sandbox Code Playgroud)
注意:在我的第一次部署中,swift 失败了,因为我没有在虚拟网络上进行委派,因此我必须在子网上添加委派才能运行 terraform。
设置好所有配置后,我运行我的 terraform,一切运行顺利,没有错误。完成后,我检查了我的网络应用程序Private Endpoint,发现它刚刚关闭。
有人可以解释一下我在这里做错了什么吗?我认为swift连接是激活的代码块,Private endpoint但显然我错过了其他东西。
为了确认我的逻辑工作流程,我尝试在门户中执行手动步骤。但令人惊讶的是我无法做到,因为我在子网上有代表团,如您所见。
非常感谢您为解决此问题提供的任何帮助和/或解释
我使用下面的代码来测试带有专用端点的 VNET 和 Web 应用程序的创建。
provider "azurerm" {
features{}
}
data "azurerm_resource_group" "rg" {
name = "ansumantest"
}
# Virtual Network
resource "azurerm_virtual_network" "vnet" {
name = "ansumanapp-vnet"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
address_space = ["10.4.0.0/16"]
}
# Subnets for App Service instances
resource "azurerm_subnet" "appserv" {
name = "frontend-app"
resource_group_name = data.azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.vnet.name
address_prefixes = ["10.4.1.0/24"]
enforce_private_link_endpoint_network_policies = true
}
# App Service Plan
resource "azurerm_app_service_plan" "frontend" {
name = "ansuman-frontend-asp"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
kind = "Linux"
reserved = true
sku {
tier = "Premium"
size = "P1V2"
}
}
# App Service
resource "azurerm_app_service" "frontend" {
name = "ansuman-frontend-app"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
app_service_plan_id = azurerm_app_service_plan.frontend.id
}
#private endpoint
resource "azurerm_private_endpoint" "example" {
name = "${azurerm_app_service.frontend.name}-endpoint"
location = data.azurerm_resource_group.rg.location
resource_group_name = data.azurerm_resource_group.rg.name
subnet_id = azurerm_subnet.appserv.id
private_service_connection {
name = "${azurerm_app_service.frontend.name}-privateconnection"
private_connection_resource_id = azurerm_app_service.frontend.id
subresource_names = ["sites"]
is_manual_connection = false
}
}
# private DNS
resource "azurerm_private_dns_zone" "example" {
name = "privatelink.azurewebsites.net"
resource_group_name = data.azurerm_resource_group.rg.name
}
#private DNS Link
resource "azurerm_private_dns_zone_virtual_network_link" "example" {
name = "${azurerm_app_service.frontend.name}-dnslink"
resource_group_name = data.azurerm_resource_group.rg.name
private_dns_zone_name = azurerm_private_dns_zone.example.name
virtual_network_id = azurerm_virtual_network.vnet.id
registration_enabled = false
}
Run Code Online (Sandbox Code Playgroud)
要求:
App service Plan有高级计划才能拥有专用端点。Private Endpointenforce_private_link_endpoint_network_policies = truesubnet has private endpoint network policies enabled , it should be disabled to be used by Private endpointprivatelink.azurewebsites.net您为 Web 应用程序创建专用端点时使用。输出:
| 归档时间: |
|
| 查看次数: |
6891 次 |
| 最近记录: |