prehistoric-shoe-97241
04/09/2024, 5:53 PMmicroscopic-arm-69377
04/09/2024, 5:58 PMprehistoric-shoe-97241
04/09/2024, 6:03 PMprehistoric-shoe-97241
04/09/2024, 6:03 PMmicroscopic-arm-69377
04/09/2024, 6:26 PMprehistoric-shoe-97241
04/09/2024, 6:40 PMmicroscopic-arm-69377
04/09/2024, 6:47 PMprehistoric-shoe-97241
04/09/2024, 7:25 PMmicroscopic-arm-69377
04/10/2024, 12:29 PMprehistoric-shoe-97241
04/10/2024, 1:11 PMprehistoric-shoe-97241
04/10/2024, 1:14 PMimport * as pulumi from "@pulumi/pulumi";
import * as azureNative from "@pulumi/azure-native";
// Create a new resource group
const resourceGroup = new azureNative.resources.ResourceGroup("resourceGroup");
// Create a virtual network
const vnet = new azureNative.network.VirtualNetwork("vnet", {
resourceGroupName: resourceGroup.name,
addressSpace: {
addressPrefixes: ["10.0.0.0/16"],
},
subnets: [{
name: "default",
addressPrefix: "10.0.1.0/24",
}],
});
// Create a subnet for the App Service Environment
const aseSubnet = new azureNative.network.Subnet("aseSubnet", {
resourceGroupName: resourceGroup.name,
virtualNetworkName: vnet.name,
addressPrefix: "10.0.2.0/24",
});
// Create an App Service Plan with an ASE
const appServicePlan = new azureNative.web.AppServicePlan("appServicePlan", {
resourceGroupName: resourceGroup.name,
sku: {
name: "I1",
tier: "Isolated",
size: "I1",
family: "I",
capacity: 1,
},
appServiceEnvironmentId: aseSubnet.id,
});
// Create a web app within the VNet
const webApp = new azureNative.web.WebApp("webApp", {
resourceGroupName: resourceGroup.name,
serverFarmId: appServicePlan.id,
siteConfig: {
appSettings: [
{
name: "WEBSITE_VNET_ROUTE_ALL",
value: "1",
},
],
},
});
// Create a SQL Server with no public network access
const sqlServer = new azureNative.sql.Server("sqlServer", {
resourceGroupName: resourceGroup.name,
administratorLogin: "sqladmin",
administratorLoginPassword: "ComplexPassword#1234",
version: "12.0",
publicNetworkAccess: "Disabled",
});
// Create an APIM instance with public access
const apim = new azureNative.apimanagement.Service("apim", {
resourceGroupName: resourceGroup.name,
publisherName: "api-publisher",
publisherEmail: "<mailto:contact@api-publisher.com|contact@api-publisher.com>",
sku: {
name: "Consumption",
capacity: 0,
},
});
// Export the Web App URL and APIM Gateway URL
export const webAppUrl = webApp.defaultHostName.apply(hostName => `https://${hostName}`);
export const apimGatewayUrl = apim.gatewayUrl;
This is the code but it doesnt assign the web app and the sql to the vnetmicroscopic-arm-69377
04/10/2024, 2:32 PMprehistoric-shoe-97241
04/10/2024, 2:54 PMmicroscopic-arm-69377
04/10/2024, 3:10 PMazure_native.network.SubnetArgs(
name=f"snet-{location_abb}-web-application-integrations",
address_prefix="10.1.0.0/24",
delegations=[azure_native.network.DelegationArgs(
name="delegation-web-applications",
service_name="Microsoft.Web/serverFarms",
)],
nat_gateway=azure_native.network.SubResourceArgs(
id=nat_web_app_services.id,
),
network_security_group=azure_native.network.NetworkSecurityGroupArgs(
id=nsg_web_applications.id,
),
private_endpoint_network_policies="Enabled",
private_link_service_network_policies="Enabled",
),
This tells Azure that the Web App is allowed to use the subnet.
Then, in my web app, I add the subnet ID through the "virtual_network_subnet_id" argument.
What I see is you're trying to get that done through the site config, but you'll want to do it through the web app's argument. Here's the page to show you that argument: azure-native.web.WebApp | Pulumi Registryprehistoric-shoe-97241
04/11/2024, 8:12 AM