From c7bb15fef70be4351f5d3017054de1fce9c03a05 Mon Sep 17 00:00:00 2001 From: Mitch Denny Date: Wed, 31 Jan 2024 14:48:48 +1100 Subject: [PATCH] Fix rabbit mq bindings in manifest. (#1985) (#2000) * Fix rabbit mq bindings in manifest. * Use 3 tag for RMQ, and checkin manifest. --- .gitignore | 3 + Aspire.sln | 24 + playground/eShopLite/AppHost/Program.cs | 2 +- .../eShopLite/AppHost/aspire-manifest.json | 27 +- .../eShopLite/CatalogDb/CatalogDb.csproj | 4 +- .../CatalogModel/CatalogModel.csproj | 17 + playground/eShopLite/CatalogModel/Model.cs | 142 ++++++ .../eShopLite/CatalogService/CatalogApi.cs | 2 +- .../CatalogService/CatalogService.csproj | 3 +- .../eShopLite/CatalogService/Program.cs | 2 +- playground/eShopLite/azure.yaml | 9 - .../eShopLite/infra/eshoplite/app.bicep | 410 ------------------ playground/eShopLite/infra/main.bicep | 31 -- .../eShopLite/infra/main.parameters.json | 12 - .../RabbitMQ/RabbitMQBuilderExtensions.cs | 8 +- 15 files changed, 222 insertions(+), 474 deletions(-) create mode 100644 playground/eShopLite/CatalogModel/CatalogModel.csproj create mode 100644 playground/eShopLite/CatalogModel/Model.cs delete mode 100644 playground/eShopLite/azure.yaml delete mode 100644 playground/eShopLite/infra/eshoplite/app.bicep delete mode 100644 playground/eShopLite/infra/main.bicep delete mode 100644 playground/eShopLite/infra/main.parameters.json diff --git a/.gitignore b/.gitignore index 4a7f90ae76..b35de17e37 100644 --- a/.gitignore +++ b/.gitignore @@ -136,3 +136,6 @@ node_modules/ # vscode python env files .env +/playground/eShopLite/.gitignore +/playground/eShopLite/azure.yaml +/playground/eShopLite/next-steps.md diff --git a/Aspire.sln b/Aspire.sln index 9b7c97973b..647bf02752 100644 --- a/Aspire.sln +++ b/Aspire.sln @@ -211,6 +211,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.AppHost", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SqlServerEndToEnd.ApiService", "playground\SqlServerEndToEnd\SqlServerEndToEnd.ApiService\SqlServerEndToEnd.ApiService.csproj", "{78ABCF96-507B-4E5F-9265-CACC3EFD4C53}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mongo", "mongo", "{C544D8A6-977E-40EA-8B1A-1FB2146A2108}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mongo.AppHost", "playground\mongo\Mongo.AppHost\Mongo.AppHost.csproj", "{8F132275-233C-4121-AC6F-352C902FA064}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mongo.ApiService", "playground\mongo\Mongo.ApiService\Mongo.ApiService.csproj", "{40EC38A2-69DB-4759-81C8-13F31090FEA6}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CatalogModel", "playground\eShopLite\CatalogModel\CatalogModel.csproj", "{83267206-9438-42CD-860C-C92E7DBAA4C3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -565,6 +573,18 @@ Global {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Debug|Any CPU.Build.0 = Debug|Any CPU {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.ActiveCfg = Release|Any CPU {78ABCF96-507B-4E5F-9265-CACC3EFD4C53}.Release|Any CPU.Build.0 = Release|Any CPU + {8F132275-233C-4121-AC6F-352C902FA064}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F132275-233C-4121-AC6F-352C902FA064}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F132275-233C-4121-AC6F-352C902FA064}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F132275-233C-4121-AC6F-352C902FA064}.Release|Any CPU.Build.0 = Release|Any CPU + {40EC38A2-69DB-4759-81C8-13F31090FEA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40EC38A2-69DB-4759-81C8-13F31090FEA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40EC38A2-69DB-4759-81C8-13F31090FEA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40EC38A2-69DB-4759-81C8-13F31090FEA6}.Release|Any CPU.Build.0 = Release|Any CPU + {83267206-9438-42CD-860C-C92E7DBAA4C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83267206-9438-42CD-860C-C92E7DBAA4C3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83267206-9438-42CD-860C-C92E7DBAA4C3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83267206-9438-42CD-860C-C92E7DBAA4C3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -664,6 +684,10 @@ Global {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0} {7616FD70-6BEC-439D-B39E-A838F939C0F9} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} {78ABCF96-507B-4E5F-9265-CACC3EFD4C53} = {2CA6AB88-21EF-4488-BB1B-3A5BAD5FE2AD} + {C544D8A6-977E-40EA-8B1A-1FB2146A2108} = {D173887B-AF42-4576-B9C1-96B9E9B3D9C0} + {8F132275-233C-4121-AC6F-352C902FA064} = {C544D8A6-977E-40EA-8B1A-1FB2146A2108} + {40EC38A2-69DB-4759-81C8-13F31090FEA6} = {C544D8A6-977E-40EA-8B1A-1FB2146A2108} + {83267206-9438-42CD-860C-C92E7DBAA4C3} = {A68BA1A5-1604-433D-9778-DC0199831C2A} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6DCEDFEC-988E-4CB3-B45B-191EB5086E0C} diff --git a/playground/eShopLite/AppHost/Program.cs b/playground/eShopLite/AppHost/Program.cs index 03006d2ffc..82843b57ef 100644 --- a/playground/eShopLite/AppHost/Program.cs +++ b/playground/eShopLite/AppHost/Program.cs @@ -11,7 +11,7 @@ .WithReference(catalogDb) .WithReplicas(2); -var messaging = builder.AddRabbitMQ("messaging"); +var messaging = builder.AddRabbitMQContainer("messaging"); var basketService = builder.AddProject("basketservice", @"..\BasketService\BasketService.csproj") .WithReference(basketCache) diff --git a/playground/eShopLite/AppHost/aspire-manifest.json b/playground/eShopLite/AppHost/aspire-manifest.json index ce750e6290..07e7caf6af 100644 --- a/playground/eShopLite/AppHost/aspire-manifest.json +++ b/playground/eShopLite/AppHost/aspire-manifest.json @@ -32,7 +32,32 @@ } }, "messaging": { - "type": "rabbitmq.server.v0" + "type": "container.v0", + "image": "rabbitmq:3", + "env": { + "RABBITMQ_DEFAULT_USER": "guest", + "RABBITMQ_DEFAULT_PASS": "{messaging.inputs.password}" + }, + "bindings": { + "tcp": { + "scheme": "tcp", + "protocol": "tcp", + "transport": "tcp", + "containerPort": 5672 + } + }, + "connectionString": "amqp://guest:{messaging.inputs.password}@{messaging.bindings.tcp.host}:{messaging.bindings.tcp.port}", + "inputs": { + "password": { + "type": "string", + "secret": true, + "default": { + "generate": { + "minLength": 10 + } + } + } + } }, "basketservice": { "type": "project.v0", diff --git a/playground/eShopLite/CatalogDb/CatalogDb.csproj b/playground/eShopLite/CatalogDb/CatalogDb.csproj index 45209bda94..e337e433fa 100644 --- a/playground/eShopLite/CatalogDb/CatalogDb.csproj +++ b/playground/eShopLite/CatalogDb/CatalogDb.csproj @@ -7,12 +7,12 @@ + - all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/playground/eShopLite/CatalogModel/CatalogModel.csproj b/playground/eShopLite/CatalogModel/CatalogModel.csproj new file mode 100644 index 0000000000..eb77f91cce --- /dev/null +++ b/playground/eShopLite/CatalogModel/CatalogModel.csproj @@ -0,0 +1,17 @@ + + + + net8.0 + enable + enable + + + + + + + + + + + diff --git a/playground/eShopLite/CatalogModel/Model.cs b/playground/eShopLite/CatalogModel/Model.cs new file mode 100644 index 0000000000..10291202e4 --- /dev/null +++ b/playground/eShopLite/CatalogModel/Model.cs @@ -0,0 +1,142 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace CatalogModel; + +public record Catalog(int FirstId, int NextId, bool IsLastPage, IEnumerable Data); + +public class CatalogDbContext(DbContextOptions options) : DbContext(options) +{ + // https://learn.microsoft.com/ef/core/performance/advanced-performance-topics#compiled-queries + + private static readonly Func> s_getCatalogItemsQuery = + EF.CompileAsyncQuery((CatalogDbContext context, int? catalogBrandId, int? before, int? after, int pageSize) => + context.CatalogItems.AsNoTracking() + .OrderBy(ci => ci.Id) + .Where(ci => catalogBrandId == null || ci.CatalogBrandId == catalogBrandId) + .Where(ci => before == null || ci.Id <= before) + .Where(ci => after == null || ci.Id >= after) + .Take(pageSize + 1)); + + public Task> GetCatalogItemsCompiledAsync(int? catalogBrandId, int? before, int? after, int pageSize) + { + return ToListAsync(s_getCatalogItemsQuery(this, catalogBrandId, before, after, pageSize)); + } + + public DbSet CatalogItems => Set(); + public DbSet CatalogBrands => Set(); + public DbSet CatalogTypes => Set(); + + protected override void OnModelCreating(ModelBuilder builder) + { + DefineCatalogBrand(builder.Entity()); + + DefineCatalogItem(builder.Entity()); + + DefineCatalogType(builder.Entity()); + } + + private static void DefineCatalogType(EntityTypeBuilder builder) + { + builder.ToTable("CatalogType"); + + builder.HasKey(ci => ci.Id); + + builder.Property(ci => ci.Id) + .UseHiLo("catalog_type_hilo") + .IsRequired(); + + builder.Property(cb => cb.Type) + .IsRequired() + .HasMaxLength(100); + } + + private static void DefineCatalogItem(EntityTypeBuilder builder) + { + builder.ToTable("Catalog"); + + builder.Property(ci => ci.Id) + .UseHiLo("catalog_hilo") + .IsRequired(); + + builder.Property(ci => ci.Name) + .IsRequired(true) + .HasMaxLength(50); + + builder.Property(ci => ci.Price) + .IsRequired(true); + + builder.Property(ci => ci.PictureFileName) + .IsRequired(false); + + builder.Ignore(ci => ci.PictureUri); + + builder.HasOne(ci => ci.CatalogBrand) + .WithMany() + .HasForeignKey(ci => ci.CatalogBrandId); + + builder.HasOne(ci => ci.CatalogType) + .WithMany() + .HasForeignKey(ci => ci.CatalogTypeId); + } + + private static void DefineCatalogBrand(EntityTypeBuilder builder) + { + builder.ToTable("CatalogBrand"); + builder.HasKey(ci => ci.Id); + + builder.Property(ci => ci.Id) + .UseHiLo("catalog_brand_hilo") + .IsRequired(); + + builder.Property(cb => cb.Brand) + .IsRequired() + .HasMaxLength(100); + } + + private static async Task> ToListAsync(IAsyncEnumerable asyncEnumerable) + { + var results = new List(); + await foreach (var value in asyncEnumerable) + { + results.Add(value); + } + + return results; + } +} + +public class CatalogType +{ + public int Id { get; set; } + public required string Type { get; set; } +} + +public class CatalogBrand +{ + public int Id { get; set; } + public required string Brand { get; set; } +} + +public class CatalogItem +{ + public int Id { get; set; } + public required string Name { get; set; } + public string? Description { get; set; } + public decimal Price { get; set; } + public required string PictureFileName { get; set; } + public string? PictureUri { get; set; } + + public int CatalogTypeId { get; set; } + public required CatalogType CatalogType { get; set; } + + public int CatalogBrandId { get; set; } + public required CatalogBrand CatalogBrand { get; set; } + public int AvailableStock { get; set; } + public int RestockThreshold { get; set; } + public int MaxStockThreshold { get; set; } + public bool OnReorder { get; set; } +} diff --git a/playground/eShopLite/CatalogService/CatalogApi.cs b/playground/eShopLite/CatalogService/CatalogApi.cs index 112d303a0f..6bc26f6db5 100644 --- a/playground/eShopLite/CatalogService/CatalogApi.cs +++ b/playground/eShopLite/CatalogService/CatalogApi.cs @@ -1,4 +1,4 @@ -using CatalogDb; +using CatalogModel; namespace CatalogService; diff --git a/playground/eShopLite/CatalogService/CatalogService.csproj b/playground/eShopLite/CatalogService/CatalogService.csproj index a4cfac7f9c..f8fe18fb87 100644 --- a/playground/eShopLite/CatalogService/CatalogService.csproj +++ b/playground/eShopLite/CatalogService/CatalogService.csproj @@ -16,10 +16,11 @@ + - + diff --git a/playground/eShopLite/CatalogService/Program.cs b/playground/eShopLite/CatalogService/Program.cs index 7aff75eeb1..a6e98091b4 100644 --- a/playground/eShopLite/CatalogService/Program.cs +++ b/playground/eShopLite/CatalogService/Program.cs @@ -1,4 +1,4 @@ -using CatalogDb; +using CatalogModel; using CatalogService; var builder = WebApplication.CreateBuilder(args); diff --git a/playground/eShopLite/azure.yaml b/playground/eShopLite/azure.yaml deleted file mode 100644 index e817d72f1b..0000000000 --- a/playground/eShopLite/azure.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json - -name: Aspire -hooks: - preprovision: - continueOnError: false - interactive: false - run: dotnet run --project AppHost\AppHost.csproj -- --target azure --output-path .\infra\eshoplite - shell: pwsh diff --git a/playground/eShopLite/infra/eshoplite/app.bicep b/playground/eShopLite/infra/eshoplite/app.bicep deleted file mode 100644 index b2ecf4c959..0000000000 --- a/playground/eShopLite/infra/eshoplite/app.bicep +++ /dev/null @@ -1,410 +0,0 @@ -param location string = resourceGroup().location -param acrPullRoleDefinitionName string = '7f951dda-4ed3-4680-a7ca-43fe172d538d' -param acrPushRoleDefinitionName string = '8311e382-0749-4cb8-b61a-304f252e45ec' -param contributorRoleDefinitionName string = 'b24988ac-6180-42a0-ab88-20f7382dd24c' -@secure() -param postgresServerPassword string = newGuid() -resource storemydata2srv 'Microsoft.DBforPostgreSQL/flexibleServers@2021-06-01' = { - name: 'pgsql${uniqueString(resourceGroup().id, 'storemydata2')}' - location: location - sku: { - name: 'Standard_D4ds_v4' - tier: 'GeneralPurpose' - } - properties: { - version: '12' - administratorLogin: 'postgres' - administratorLoginPassword: postgresServerPassword - storage: { - storageSizeGB: 128 - } - } -} -resource cachymccacheface2 'Microsoft.Cache/redis@2022-06-01' = { - name: 'redis${uniqueString(resourceGroup().id, 'cachymccacheface2')}' - location: location - properties: { - sku: { - name: 'Basic' - family: 'C' - capacity: 0 - } - } -} -resource logWorkspace 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { - name: 'logs${uniqueString(resourceGroup().id)}' - location: location - properties: { - sku: { - name: 'PerGB2018' - } - } -} -resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = { - name: 'env${uniqueString(resourceGroup().id)}' - location: location - properties: { - appLogsConfiguration: { - destination: 'log-analytics' - logAnalyticsConfiguration: { - customerId: logWorkspace.properties.customerId - sharedKey: logWorkspace.listKeys().primarySharedKey - } - } - } -} -resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' = { - name: 'registry${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Basic' - } -} -resource acrPushIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { - name: 'id${uniqueString(resourceGroup().id, 'push')}' - location: location -} -resource acrPullIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = { - name: 'id${uniqueString(resourceGroup().id, 'pull')}' - location: location -} -resource contributorRoleDefinition 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { - name: contributorRoleDefinitionName - scope: subscription() -} -resource acrPullRoleDefinition 'Microsoft.Authorization/roleDefinitions@2022-04-01' existing = { - name: acrPullRoleDefinitionName - scope: subscription() -} -resource contributorRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - name: guid(acrPushIdentity.id, contributorRoleDefinitionName, containerRegistry.id) - properties: { - principalId: acrPushIdentity.properties.principalId - roleDefinitionId: contributorRoleDefinition.id - principalType: 'ServicePrincipal' - } - scope: containerRegistry -} -resource acrPullRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - name: guid(acrPullIdentity.id, acrPullRoleDefinitionName, containerRegistry.id) - properties: { - principalId: acrPullIdentity.properties.principalId - roleDefinitionId: acrPullRoleDefinition.id - principalType: 'ServicePrincipal' - } - scope: containerRegistry -} -resource containerImageBootstrapScript0 'Microsoft.Resources/deploymentScripts@2020-10-01' = { - name: 'import${uniqueString(resourceGroup().id, 'containerImageBootstrapScript0')}' - location: location - kind: 'AzureCLI' - identity: { - type: 'UserAssigned' - userAssignedIdentities: { - '${acrPushIdentity.id}': { - } - } - } - properties: { - azCliVersion: '2.47.0' - retentionInterval: 'P1D' - scriptContent: 'az acr import --name ${containerRegistry.name} --source mcr.microsoft.com/azuredocs/containerapps-helloworld:latest --resource-group ${resourceGroup().name} --image catalog:latest' - } -} -resource containerApp0 'Microsoft.App/containerApps@2022-03-01' = { - name: 'catalog-${uniqueString(resourceGroup().id)}' - location: location - dependsOn: [ -containerImageBootstrapScript0 ] - identity: { - type: 'SystemAssigned,UserAssigned' - userAssignedIdentities: { - '${acrPullIdentity.id}': { - } - } - } - properties: { - managedEnvironmentId: containerAppEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 80 - } - registries: [ - { - identity: acrPullIdentity.id - server: containerRegistry.properties.loginServer - } - ] - } - template: { - scale: { - minReplicas: 2 - } - containers: [ - { - name: 'container${uniqueString(resourceGroup().id)}' - image: '${containerRegistry.properties.loginServer}/catalog:latest' - env: [ - { - name: 'ConnectionStrings__Aspire.PostgreSQL' - value: 'Host=localhost;Database=catalog;Username=postgres;Password=postgres' - } - ] - resources: { - cpu: '0.25' - memory: '0.5Gi' - } - } - ] - } - } -} -resource containerImageBootstrapScript1 'Microsoft.Resources/deploymentScripts@2020-10-01' = { - name: 'import${uniqueString(resourceGroup().id, 'containerImageBootstrapScript1')}' - location: location - kind: 'AzureCLI' - identity: { - type: 'UserAssigned' - userAssignedIdentities: { - '${acrPushIdentity.id}': { - } - } - } - properties: { - azCliVersion: '2.47.0' - retentionInterval: 'P1D' - scriptContent: 'az acr import --name ${containerRegistry.name} --source mcr.microsoft.com/azuredocs/containerapps-helloworld:latest --resource-group ${resourceGroup().name} --image basket:latest' - } -} -resource containerApp1 'Microsoft.App/containerApps@2022-03-01' = { - name: 'basket-${uniqueString(resourceGroup().id)}' - location: location - dependsOn: [ -containerImageBootstrapScript1 ] - identity: { - type: 'SystemAssigned,UserAssigned' - userAssignedIdentities: { - '${acrPullIdentity.id}': { - } - } - } - properties: { - managedEnvironmentId: containerAppEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 80 - } - registries: [ - { - identity: acrPullIdentity.id - server: containerRegistry.properties.loginServer - } - ] - } - template: { - scale: { - minReplicas: 2 - } - containers: [ - { - name: 'container${uniqueString(resourceGroup().id)}' - image: '${containerRegistry.properties.loginServer}/basket:latest' - env: [ - ] - resources: { - cpu: '0.25' - memory: '0.5Gi' - } - } - ] - } - } -} -resource containerImageBootstrapScript2 'Microsoft.Resources/deploymentScripts@2020-10-01' = { - name: 'import${uniqueString(resourceGroup().id, 'containerImageBootstrapScript2')}' - location: location - kind: 'AzureCLI' - identity: { - type: 'UserAssigned' - userAssignedIdentities: { - '${acrPushIdentity.id}': { - } - } - } - properties: { - azCliVersion: '2.47.0' - retentionInterval: 'P1D' - scriptContent: 'az acr import --name ${containerRegistry.name} --source mcr.microsoft.com/azuredocs/containerapps-helloworld:latest --resource-group ${resourceGroup().name} --image myfrontend:latest' - } -} -resource containerApp2 'Microsoft.App/containerApps@2022-03-01' = { - name: 'myfrontend-${uniqueString(resourceGroup().id)}' - location: location - dependsOn: [ -containerImageBootstrapScript2 ] - identity: { - type: 'SystemAssigned,UserAssigned' - userAssignedIdentities: { - '${acrPullIdentity.id}': { - } - } - } - properties: { - managedEnvironmentId: containerAppEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 80 - } - registries: [ - { - identity: acrPullIdentity.id - server: containerRegistry.properties.loginServer - } - ] - } - template: { - scale: { - minReplicas: 2 - } - containers: [ - { - name: 'container${uniqueString(resourceGroup().id)}' - image: '${containerRegistry.properties.loginServer}/myfrontend:latest' - env: [ - ] - resources: { - cpu: '0.25' - memory: '0.5Gi' - } - } - ] - } - } -} -resource containerImageBootstrapScript3 'Microsoft.Resources/deploymentScripts@2020-10-01' = { - name: 'import${uniqueString(resourceGroup().id, 'containerImageBootstrapScript3')}' - location: location - kind: 'AzureCLI' - identity: { - type: 'UserAssigned' - userAssignedIdentities: { - '${acrPushIdentity.id}': { - } - } - } - properties: { - azCliVersion: '2.47.0' - retentionInterval: 'P1D' - scriptContent: 'az acr import --name ${containerRegistry.name} --source mcr.microsoft.com/azuredocs/containerapps-helloworld:latest --resource-group ${resourceGroup().name} --image orderprocessor:latest' - } -} -resource containerApp3 'Microsoft.App/containerApps@2022-03-01' = { - name: 'orderprocessor-${uniqueString(resourceGroup().id)}' - location: location - dependsOn: [ -containerImageBootstrapScript3 ] - identity: { - type: 'SystemAssigned,UserAssigned' - userAssignedIdentities: { - '${acrPullIdentity.id}': { - } - } - } - properties: { - managedEnvironmentId: containerAppEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 80 - } - registries: [ - { - identity: acrPullIdentity.id - server: containerRegistry.properties.loginServer - } - ] - } - template: { - scale: { - minReplicas: 2 - } - containers: [ - { - name: 'container${uniqueString(resourceGroup().id)}' - image: '${containerRegistry.properties.loginServer}/orderprocessor:latest' - env: [ - ] - resources: { - cpu: '0.25' - memory: '0.5Gi' - } - } - ] - } - } -} -resource containerImageBootstrapScript4 'Microsoft.Resources/deploymentScripts@2020-10-01' = { - name: 'import${uniqueString(resourceGroup().id, 'containerImageBootstrapScript4')}' - location: location - kind: 'AzureCLI' - identity: { - type: 'UserAssigned' - userAssignedIdentities: { - '${acrPushIdentity.id}': { - } - } - } - properties: { - azCliVersion: '2.47.0' - retentionInterval: 'P1D' - scriptContent: 'az acr import --name ${containerRegistry.name} --source mcr.microsoft.com/azuredocs/containerapps-helloworld:latest --resource-group ${resourceGroup().name} --image apigateway:latest' - } -} -resource containerApp4 'Microsoft.App/containerApps@2022-03-01' = { - name: 'apigateway-${uniqueString(resourceGroup().id)}' - location: location - dependsOn: [ -containerImageBootstrapScript4 ] - identity: { - type: 'SystemAssigned,UserAssigned' - userAssignedIdentities: { - '${acrPullIdentity.id}': { - } - } - } - properties: { - managedEnvironmentId: containerAppEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 80 - } - registries: [ - { - identity: acrPullIdentity.id - server: containerRegistry.properties.loginServer - } - ] - } - template: { - scale: { - minReplicas: 2 - } - containers: [ - { - name: 'container${uniqueString(resourceGroup().id)}' - image: '${containerRegistry.properties.loginServer}/apigateway:latest' - env: [ - ] - resources: { - cpu: '0.25' - memory: '0.5Gi' - } - } - ] - } - } -} diff --git a/playground/eShopLite/infra/main.bicep b/playground/eShopLite/infra/main.bicep deleted file mode 100644 index c7e8400ed5..0000000000 --- a/playground/eShopLite/infra/main.bicep +++ /dev/null @@ -1,31 +0,0 @@ -targetScope = 'subscription' - -@minLength(1) -@maxLength(64) -@description('Name of the environment that can be used as part of naming resource convention') -param environmentName string - -@minLength(1) -@description('Primary location for all resources') -param location string - -// Tags that should be applied to all resources. -// -// Note that 'azd-service-name' tags should be applied separately to service host resources. -// Example usage: -// tags: union(tags, { 'azd-service-name': }) -var tags = { - 'azd-env-name': environmentName -} - -resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = { - name: 'rg-${environmentName}' - location: location - tags: tags -} - -// Manually added! -module app 'myapp/app.bicep' = { - name: 'app-${environmentName}' - scope: rg -} diff --git a/playground/eShopLite/infra/main.parameters.json b/playground/eShopLite/infra/main.parameters.json deleted file mode 100644 index f1600cfbcf..0000000000 --- a/playground/eShopLite/infra/main.parameters.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "environmentName": { - "value": "${AZURE_ENV_NAME}" - }, - "location": { - "value": "${AZURE_LOCATION}" - } - } -} diff --git a/src/Aspire.Hosting/RabbitMQ/RabbitMQBuilderExtensions.cs b/src/Aspire.Hosting/RabbitMQ/RabbitMQBuilderExtensions.cs index ea75229421..034dad2ee8 100644 --- a/src/Aspire.Hosting/RabbitMQ/RabbitMQBuilderExtensions.cs +++ b/src/Aspire.Hosting/RabbitMQ/RabbitMQBuilderExtensions.cs @@ -26,8 +26,7 @@ public static IResourceBuilder AddRabbitMQContainer(t var rabbitMq = new RabbitMQContainerResource(name, password); return builder.AddResource(rabbitMq) .WithAnnotation(new EndpointAnnotation(ProtocolType.Tcp, port: port, containerPort: 5672)) - .WithAnnotation(new EndpointAnnotation(ProtocolType.Tcp, uriScheme: "http", name: "management", port: null, containerPort: 15672)) - .WithAnnotation(new ContainerImageAnnotation { Image = "rabbitmq", Tag = "3-management" }) + .WithAnnotation(new ContainerImageAnnotation { Image = "rabbitmq", Tag = "3" }) .WithManifestPublishingCallback(context => WriteRabbitMQContainerToManifest(context, rabbitMq)) .WithEnvironment("RABBITMQ_DEFAULT_USER", "guest") .WithEnvironment(context => @@ -56,8 +55,7 @@ public static IResourceBuilder AddRabbitMQ(this IDistrib var rabbitMq = new RabbitMQServerResource(name, password); return builder.AddResource(rabbitMq) .WithAnnotation(new EndpointAnnotation(ProtocolType.Tcp, containerPort: 5672)) - .WithAnnotation(new EndpointAnnotation(ProtocolType.Tcp, uriScheme: "http", name: "management", port: null, containerPort: 15672)) - .WithAnnotation(new ContainerImageAnnotation { Image = "rabbitmq", Tag = "3-management" }) + .WithAnnotation(new ContainerImageAnnotation { Image = "rabbitmq", Tag = "3" }) .WithManifestPublishingCallback(WriteRabbitMQServerToManifest) .WithEnvironment("RABBITMQ_DEFAULT_USER", "guest") .WithEnvironment("RABBITMQ_DEFAULT_PASS", () => rabbitMq.Password); @@ -73,7 +71,7 @@ private static void WriteRabbitMQContainerToManifest(ManifestPublishingContext c context.WriteContainer(resource); context.Writer.WriteString( // "connectionString": "...", "connectionString", - $"amqp://guest:{{{resource.Name}.inputs.password}}@{{{resource.Name}.bindings.management.host}}:{{{resource.Name}.bindings.management.port}}"); + $"amqp://guest:{{{resource.Name}.inputs.password}}@{{{resource.Name}.bindings.tcp.host}}:{{{resource.Name}.bindings.tcp.port}}"); context.Writer.WriteStartObject("inputs"); // "inputs": { context.Writer.WriteStartObject("password"); // "password": { context.Writer.WriteString("type", "string"); // "type": "string",