diff --git a/playground/AzureAppService/AzureAppService.AppHost/api.module.bicep b/playground/AzureAppService/AzureAppService.AppHost/api.module.bicep index c5b1d87d429..aaa175d0bb7 100644 --- a/playground/AzureAppService/AzureAppService.AppHost/api.module.bicep +++ b/playground/AzureAppService/AzureAppService.AppHost/api.module.bicep @@ -26,6 +26,17 @@ param api_identity_outputs_id string param api_identity_outputs_clientid string +resource mainContainer 'Microsoft.Web/sites/sitecontainers@2024-04-01' = { + name: 'main' + properties: { + authType: 'UserAssigned' + image: api_containerimage + isMain: true + userManagedIdentityClientId: infra_outputs_azure_container_registry_managed_identity_client_id + } + parent: webapp +} + resource webapp 'Microsoft.Web/sites@2024-04-01' = { name: take('${toLower('api')}-${uniqueString(resourceGroup().id)}', 60) location: location @@ -33,7 +44,7 @@ resource webapp 'Microsoft.Web/sites@2024-04-01' = { serverFarmId: infra_outputs_planid keyVaultReferenceIdentity: api_identity_outputs_id siteConfig: { - linuxFxVersion: 'DOCKER|${api_containerimage}' + linuxFxVersion: 'SITECONTAINERS' acrUseManagedIdentityCreds: true acrUserManagedIdentityID: infra_outputs_azure_container_registry_managed_identity_client_id appSettings: [ diff --git a/playground/AzureAppService/AzureAppService.AppHost/infra.module.bicep b/playground/AzureAppService/AzureAppService.AppHost/infra.module.bicep index 4cd6db10e5e..cfc3f265819 100644 --- a/playground/AzureAppService/AzureAppService.AppHost/infra.module.bicep +++ b/playground/AzureAppService/AzureAppService.AppHost/infra.module.bicep @@ -38,8 +38,8 @@ resource infra_asplan 'Microsoft.Web/serverfarms@2024-04-01' = { } kind: 'Linux' sku: { - name: 'B1' - tier: 'Basic' + name: 'P0V3' + tier: 'Premium' } } diff --git a/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs b/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs index 2bf9d108d1a..c9ad2dc78d5 100644 --- a/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs +++ b/src/Aspire.Hosting.Azure.AppService/AzureAppServiceEnvironmentExtensions.cs @@ -86,8 +86,8 @@ public static IResourceBuilder AddAzureAppSe { Sku = new AppServiceSkuDescription { - Name = "B1", - Tier = "Basic" + Name = "P0V3", + Tier = "Premium" }, Kind = "Linux", IsReserved = true diff --git a/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs b/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs index 18c4b92c0fe..2021365f225 100644 --- a/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs +++ b/src/Aspire.Hosting.Azure.AppService/AzureAppServiceWebsiteContext.cs @@ -212,9 +212,10 @@ public void BuildWebSite(AzureResourceInfrastructure infra) // Use the host name as the name of the web app Name = HostName, AppServicePlanId = appServicePlanParameter, + // Creating the app service with new sidecar configuration SiteConfig = new SiteConfigProperties() { - LinuxFxVersion = BicepFunction.Interpolate($"DOCKER|{containerImage}"), + LinuxFxVersion = "SITECONTAINERS", AcrUserManagedIdentityId = acrClientIdParameter, UseManagedIdentityCreds = true, AppSettings = [] @@ -226,6 +227,19 @@ public void BuildWebSite(AzureResourceInfrastructure infra) }, }; + // Defining the main container for the app service + var mainContainer = new SiteContainer("mainContainer") + { + Parent = webSite, + Name = "main", + Image = containerImage, + AuthType = SiteContainerAuthType.UserAssigned, + UserManagedIdentityClientId = acrClientIdParameter, + IsMain = true + }; + + infra.Add(mainContainer); + foreach (var kv in EnvironmentVariables) { var (val, secretType) = ProcessValue(kv.Value); diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsDeploymentTargetWithContainerAppToProjectResources.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsDeploymentTargetWithContainerAppToProjectResources.verified.bicep index ab46365a6f2..2ddd65a51ff 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsDeploymentTargetWithContainerAppToProjectResources.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsDeploymentTargetWithContainerAppToProjectResources.verified.bicep @@ -13,13 +13,24 @@ param api_containerimage string param api_containerport string +resource mainContainer 'Microsoft.Web/sites/sitecontainers@2024-04-01' = { + name: 'main' + properties: { + authType: 'UserAssigned' + image: api_containerimage + isMain: true + userManagedIdentityClientId: env_outputs_azure_container_registry_managed_identity_client_id + } + parent: webapp +} + resource webapp 'Microsoft.Web/sites@2024-04-01' = { name: take('${toLower('api')}-${uniqueString(resourceGroup().id)}', 60) location: location properties: { serverFarmId: env_outputs_planid siteConfig: { - linuxFxVersion: 'DOCKER|${api_containerimage}' + linuxFxVersion: 'SITECONTAINERS' acrUseManagedIdentityCreds: true acrUserManagedIdentityID: env_outputs_azure_container_registry_managed_identity_client_id appSettings: [ diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsEnvironmentResource.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsEnvironmentResource.verified.bicep index b1f6b0e63e9..5bc76334a8a 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsEnvironmentResource.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.AddContainerAppEnvironmentAddsEnvironmentResource.verified.bicep @@ -38,8 +38,8 @@ resource env_asplan 'Microsoft.Web/serverfarms@2024-04-01' = { } kind: 'Linux' sku: { - name: 'B1' - tier: 'Basic' + name: 'P0V3' + tier: 'Premium' } } @@ -51,4 +51,4 @@ output AZURE_CONTAINER_REGISTRY_ENDPOINT string = env_acr.properties.loginServer output AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_ID string = env_mi.id -output AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_CLIENT_ID string = env_mi.properties.clientId +output AZURE_CONTAINER_REGISTRY_MANAGED_IDENTITY_CLIENT_ID string = env_mi.properties.clientId \ No newline at end of file diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.EndpointReferencesAreResolvedAcrossProjects.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.EndpointReferencesAreResolvedAcrossProjects.verified.bicep index 24905dcea9f..4cb9011e459 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.EndpointReferencesAreResolvedAcrossProjects.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.EndpointReferencesAreResolvedAcrossProjects.verified.bicep @@ -13,13 +13,24 @@ param project2_containerimage string param project2_containerport string +resource mainContainer 'Microsoft.Web/sites/sitecontainers@2024-04-01' = { + name: 'main' + properties: { + authType: 'UserAssigned' + image: project2_containerimage + isMain: true + userManagedIdentityClientId: env_outputs_azure_container_registry_managed_identity_client_id + } + parent: webapp +} + resource webapp 'Microsoft.Web/sites@2024-04-01' = { name: take('${toLower('project2')}-${uniqueString(resourceGroup().id)}', 60) location: location properties: { serverFarmId: env_outputs_planid siteConfig: { - linuxFxVersion: 'DOCKER|${project2_containerimage}' + linuxFxVersion: 'SITECONTAINERS' acrUseManagedIdentityCreds: true acrUserManagedIdentityID: env_outputs_azure_container_registry_managed_identity_client_id appSettings: [ diff --git a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.KeyvaultReferenceHandling.verified.bicep b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.KeyvaultReferenceHandling.verified.bicep index c1446f9b50b..bdd164765cd 100644 --- a/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.KeyvaultReferenceHandling.verified.bicep +++ b/tests/Aspire.Hosting.Azure.Tests/Snapshots/AzureAppServiceTests.KeyvaultReferenceHandling.verified.bicep @@ -17,6 +17,17 @@ param api_identity_outputs_id string param api_identity_outputs_clientid string +resource mainContainer 'Microsoft.Web/sites/sitecontainers@2024-04-01' = { + name: 'main' + properties: { + authType: 'UserAssigned' + image: api_containerimage + isMain: true + userManagedIdentityClientId: env_outputs_azure_container_registry_managed_identity_client_id + } + parent: webapp +} + resource mydb_kv_outputs_name_kv 'Microsoft.KeyVault/vaults@2023-07-01' existing = { name: mydb_kv_outputs_name } @@ -33,7 +44,7 @@ resource webapp 'Microsoft.Web/sites@2024-04-01' = { serverFarmId: env_outputs_planid keyVaultReferenceIdentity: api_identity_outputs_id siteConfig: { - linuxFxVersion: 'DOCKER|${api_containerimage}' + linuxFxVersion: 'SITECONTAINERS' acrUseManagedIdentityCreds: true acrUserManagedIdentityID: env_outputs_azure_container_registry_managed_identity_client_id appSettings: [