Skip to content

PublishAsExisting on AzureAppServiceEnvironmentResource doesn't use existing #14382

@rjpowers10

Description

@rjpowers10

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Aspire.Hosting.Azure.AppService version 13.1.0-preview.1.25616.3

Calling the PublishAsExisting method on IResourceBuilder<AzureAppServiceEnvironmentResource> appears to have no effect on the generated bicep. I know it's in preview but the docs suggest it should work.

The same result happens whether I use AsExisting or PublishAsExisting.

Expected Behavior

The bicep is generated to use an existing app service plan.

Steps To Reproduce

Create the starter app

aspire new aspire-starter -n AspireApp -o AspireApp

Add App Service

aspire add azure-appservice
✔  The package Aspire.Hosting.Azure.AppService::13.1.0-preview.1.25616.3 was added successfully.

Replace the contents of AppHost.cs as follows.

var builder = DistributedApplication.CreateBuilder(args);

var existingAppServicePlanName = builder.AddParameter("ExistingAppServicePlanName", "existing-plan-name");
var existingAppServicePlanResourceGroup = builder.AddParameter("ExistingAppServicePlanResourceGroup", "existing-resource-group");

builder.AddAzureAppServiceEnvironment("env").PublishAsExisting(existingAppServicePlanName, existingAppServicePlanResourceGroup);

builder.Build().Run();

Publish

aspire publish

We can see in env.bicep that the existing keyword is missing.

resource env_asplan 'Microsoft.Web/serverfarms@2025-03-01' = {
  name: take('envasplan-${uniqueString(resourceGroup().id)}', 60)
  location: location
  properties: {
    perSiteScaling: true
    reserved: true
  }
  kind: 'Linux'
  sku: {
    name: 'P0V3'
    tier: 'Premium'
  }
}

In main.bicep my parameters ExistingAppServicePlanResourceGroup and ExistingAppServicePlanName appear but are unused.

targetScope = 'subscription'

param resourceGroupName string

param location string

param principalId string

param ExistingAppServicePlanResourceGroup string

param ExistingAppServicePlanName string

resource rg 'Microsoft.Resources/resourceGroups@2023-07-01' = {
  name: resourceGroupName
  location: location
}

module env_acr 'env-acr/env-acr.bicep' = {
  name: 'env-acr'
  scope: rg
  params: {
    location: location
  }
}

module env 'env/env.bicep' = {
  name: 'env'
  scope: rg
  params: {
    location: location
    env_acr_outputs_name: env_acr.outputs.name
    userPrincipalId: principalId
  }
}

Exceptions (if any)

No response

.NET Version info

.NET SDK:
Version: 10.0.102
Commit: 4452502459
Workload version: 10.0.100-manifests.6d969a7e
MSBuild version: 18.0.7+445250245

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.102\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.2
Architecture: x64
Commit: 4452502459

.NET SDKs installed:
9.0.309 [C:\Program Files\dotnet\sdk]
10.0.102 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.23 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Anything else?

Aspire version 13.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions