-
Notifications
You must be signed in to change notification settings - Fork 923
Added support for Aspire dashboard in App Service #11671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidfowl
merged 23 commits into
microsoft:main
from
ShilpiRach:shilpirach/appsvc_dashboard
Oct 7, 2025
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3aa796d
Added support for Aspire dashboard in App Service
ShilpiR 4626741
Fixed failing tests
ShilpiR 2baefd2
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironment…
ShilpiRach f21c564
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironment…
ShilpiRach 622ba2d
Added option to exclude dashboard and moved contributor identity to d…
ShilpiR c0cca3a
Added appsetting to suppress unsecured warning
ShilpiR 45968a4
Merge branch 'main' into shilpirach/appsvc_dashboard
ShilpiRach a669727
Fixed failing unit tests
ShilpiR 77aa4a1
Merge branch 'shilpirach/appsvc_dashboard' of https://github.com/Shil…
ShilpiR a554e77
Made parameter dashboardUri conditional in web app bicep templates
ShilpiR d1eac7c
Publishing DashboardUri paramater only when dashboard is enabled
ShilpiR df38b1c
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironment…
ShilpiRach 26793ea
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironment…
ShilpiRach ae6fec2
Handled PR feedback and added support to log dashboard Uri
ShilpiR 884857c
Updated a comment
ShilpiR da816ef
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironment…
davidfowl ab80970
Merge branch 'dotnet:main' into shilpirach/appsvc_dashboard
ShilpiRach e43750e
Handled scenario where there are multiple Aspire environments in a si…
ShilpiR 5f553ef
Merge from aspire repo (main)
ShilpiR 9d3200b
Added Reader role assignment to managed identity for dashboard
ShilpiR 378a9d7
Update src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteCont…
ShilpiRach c39fac6
Taking a nit change
ShilpiR 96f5683
Merge branch 'shilpirach/appsvc_dashboard' of https://github.com/Shil…
ShilpiR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentUtility.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Azure.Core; | ||
| using Azure.Provisioning; | ||
| using Azure.Provisioning.AppService; | ||
| using Azure.Provisioning.Expressions; | ||
| using Azure.Provisioning.Resources; | ||
| using Azure.Provisioning.Roles; | ||
|
|
||
| namespace Aspire.Hosting.Azure.AppService; | ||
|
|
||
| internal static class AzureAppServiceEnvironmentUtility | ||
| { | ||
| const string ResourceName = "dashboard"; | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
|
|
||
| public static BicepValue<string> DashboardHostName => BicepFunction.Take( | ||
| BicepFunction.Interpolate($"{BicepFunction.ToLower(ResourceName)}-{BicepFunction.GetUniqueString(BicepFunction.GetResourceGroup().Id)}"), 60); | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
|
|
||
| public static WebSite AddDashboard(AzureResourceInfrastructure infra, | ||
| UserAssignedIdentity otelIdentity, | ||
| UserAssignedIdentity contributorIdentity, | ||
| BicepValue<ResourceIdentifier> appServicePlanId) | ||
| { | ||
| var acrClientIdParameter = otelIdentity.ClientId; | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| var contributorMidParameter = contributorIdentity.Id; | ||
| var contributorClientIdParameter = contributorIdentity.ClientId; | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
|
|
||
| var webSite = new WebSite("webapp") | ||
|
davidfowl marked this conversation as resolved.
Outdated
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| { | ||
| // Use the host name as the name of the web app | ||
| Name = DashboardHostName, | ||
| AppServicePlanId = appServicePlanId, | ||
| // Aspire dashboards are created with a new kind aspiredashboard | ||
| Kind = "app,linux,aspiredashboard", | ||
| SiteConfig = new SiteConfigProperties() | ||
| { | ||
| LinuxFxVersion = "ASPIREDASHBOARD|1.0", | ||
|
ShilpiRach marked this conversation as resolved.
|
||
| AcrUserManagedIdentityId = acrClientIdParameter, | ||
| UseManagedIdentityCreds = true, | ||
| IsHttp20Enabled = true, | ||
| Http20ProxyFlag = 1, | ||
|
ShilpiRach marked this conversation as resolved.
|
||
| // Setting NumberOfWorkers to 1 to ensure dashboard runs of 1 instance | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| NumberOfWorkers = 1, | ||
| // IsAlwaysOn set to true ensures the app is always running | ||
| IsAlwaysOn = true, | ||
| AppSettings = [] | ||
| }, | ||
| Identity = new ManagedServiceIdentity() | ||
| { | ||
| ManagedServiceIdentityType = ManagedServiceIdentityType.UserAssigned, | ||
| UserAssignedIdentities = [] | ||
| } | ||
| }; | ||
|
|
||
| //var acrMid = BicepFunction.Interpolate($"{acrMidParameter}").Compile().ToString(); | ||
| //webSite.Identity.UserAssignedIdentities[acrMid] = new UserAssignedIdentityDetails(); | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| var contributorMid = BicepFunction.Interpolate($"{contributorMidParameter}").Compile().ToString(); | ||
| webSite.Identity.UserAssignedIdentities[contributorMid] = new UserAssignedIdentityDetails(); | ||
|
|
||
| // Security is handled by app service platform | ||
|
ShilpiRach marked this conversation as resolved.
|
||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "Dashboard__Frontend__AuthMode", Value = "Unsecured" }); | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "Dashboard__Otlp__AuthMode", Value = "Unsecured" }); | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "Dashboard__ResourceServiceClient__AuthMode", Value = "Unsecured" }); | ||
| // Dashboard ports | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "WEBSITES_PORT", Value = "5000" }); | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "HTTP20_ONLY_PORT", Value = "4317" }); | ||
| // Enable SCM preloading to ensure dashboard is always available | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "WEBSITE_START_SCM_WITH_PRELOAD", Value = "true" }); | ||
| // Appsettings related to managed identity for auth | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "AZURE_CLIENT_ID", Value = contributorClientIdParameter }); | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "ALLOWED_MANAGED_IDENTITIES", Value = acrClientIdParameter }); | ||
| infra.Add(webSite); | ||
|
|
||
| return webSite; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,6 +212,7 @@ public void BuildWebSite(AzureResourceInfrastructure infra) | |
| var acrMidParameter = environmentContext.Environment.ContainerRegistryManagedIdentityId.AsProvisioningParameter(infra); | ||
| var acrClientIdParameter = environmentContext.Environment.ContainerRegistryClientId.AsProvisioningParameter(infra); | ||
| var containerImage = AllocateParameter(new ContainerImageReference(Resource, environmentContext.ServiceProvider)); | ||
| var dashboardUri = environmentContext.Environment.DashboardUriReference.AsProvisioningParameter(infra); | ||
|
ShilpiRach marked this conversation as resolved.
Outdated
|
||
|
|
||
| var webSite = new WebSite("webapp") | ||
| { | ||
|
|
@@ -224,6 +225,9 @@ public void BuildWebSite(AzureResourceInfrastructure infra) | |
| LinuxFxVersion = "SITECONTAINERS", | ||
| AcrUserManagedIdentityId = acrClientIdParameter, | ||
| UseManagedIdentityCreds = true, | ||
| // Setting NumberOfWorkers to maximum allowed value for Premium SKU | ||
| // https://learn.microsoft.com/en-us/azure/app-service/manage-scale-up | ||
| NumberOfWorkers = 30, | ||
|
Comment on lines
+228
to
+233
|
||
| AppSettings = [] | ||
| }, | ||
| Identity = new ManagedServiceIdentity() | ||
|
|
@@ -323,6 +327,8 @@ static FunctionCallExpression Join(BicepExpression args, string delimeter) => | |
| } | ||
| #pragma warning restore ASPIREPROBES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed. | ||
|
|
||
| AddDashboardSettings(webSite, acrClientIdParameter, dashboardUri); | ||
|
|
||
| infra.Add(webSite); | ||
|
|
||
| // Allow users to customize the web app here | ||
|
|
@@ -362,6 +368,15 @@ private ProvisioningParameter AllocateParameter(IManifestExpressionProvider para | |
| { | ||
| return parameter.AsProvisioningParameter(Infra, isSecure: secretType == SecretType.Normal); | ||
| } | ||
| private void AddDashboardSettings(WebSite webSite, ProvisioningParameter acrClientIdParameter, ProvisioningParameter dashboardUri) | ||
| { | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "OTEL_SERVICE_NAME", Value = resource.Name }); | ||
|
ShilpiRach marked this conversation as resolved.
|
||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "OTEL_EXPORTER_OTLP_PROTOCOL", Value = "grpc" }); | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "OTEL_EXPORTER_OTLP_ENDPOINT", Value = "http://localhost:6001" }); | ||
|
ShilpiRach marked this conversation as resolved.
|
||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "WEBSITE_ENABLE_ASPIRE_OTEL_SIDECAR", Value = "true" }); | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "OTEL_COLLECTOR_URL", Value = dashboardUri }); | ||
| webSite.SiteConfig.AppSettings.Add(new AppServiceNameValuePair { Name = "OTEL_CLIENT_ID", Value = acrClientIdParameter }); | ||
| } | ||
|
|
||
| enum SecretType | ||
| { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.