Add a Subnet to a App Service App? #18734
|
Using aspire for setting up my subnets, works fin for my ACA containers. var vnet = builder.AddAzureVirtualNetwork("aca-vnet");
var acaSubnet = vnet.AddSubnet("aca-subnet", "10.0.1.0/24");
var appSvcSubnet = vnet.AddSubnet("appsvc-subnet", "10.0.0.0/24");
var acaEnv = builder.AddAzureContainerAppEnvironment("dc-aca-env")
.WithDelegatedSubnet(acaSubnet);
var appServiceEnv = builder.AddAzureAppServiceEnvironment("rc-app-service-env")
.ConfigureInfrastructure(infra =>
{
var resources = infra.GetProvisionableResources();
var plan = resources.OfType<AppServicePlan>().Single();
plan.Sku = new AppServiceSkuDescription
{
Name = "B3",
Tier = "Basic"
};
plan.Tags.Add("Environment", "Test");
plan.Tags.Add("CostCenter", "Engineering");
});
Can't figure out how to do the same for App Services :( nb. Plan can be upgraded to Premium if needed, this is just testing for now. |
Replies: 1 comment 12 replies
|
You configure this on each App Service website, rather than on Delegate the subnet to #pragma warning disable ASPIREAZURE003
using Aspire.Hosting.Azure;
var vnet = builder.AddAzureVirtualNetwork("app-vnet");
var subnet = vnet.AddSubnet("appservice-subnet", "10.0.0.0/24");
subnet.WithAnnotation(new AzureSubnetServiceDelegationAnnotation(
"appservice-delegation",
"Microsoft.Web/serverFarms"));
builder.AddAzureAppServiceEnvironment("appservice");
builder.AddProject<Projects.Web>("web")
.WithExternalHttpEndpoints()
.PublishAsAzureAppServiceWebsite((infrastructure, site) =>
{
site.VirtualNetworkSubnetId =
subnet.Resource.Id.AsProvisioningParameter(infrastructure);
});I tested this end to end with Aspire 13.4.6 using One additional caveat for the B3 configuration in your example: Aspire's default Premium configuration sets each website's site.SiteConfig.NumberOfWorkers = 3;Alternatively, keep the default Premium plan and omit that setting. App Service VNet integration controls outbound access from the app into the virtual network. If you also need private inbound access to the app, that is configured separately with a private endpoint. |
You configure this on each App Service website, rather than on
AddAzureAppServiceEnvironment.Delegate the subnet to
Microsoft.Web/serverFarms, then usePublishAsAzureAppServiceWebsiteto setWebSite.VirtualNetworkSubnetId: