From f59c9e5ce811735e2760fe459d672852237ec34c Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Wed, 12 Jul 2023 08:54:36 -0700 Subject: [PATCH 01/12] First draft of working aws eshop recipes --- reference-apps/eshop/iac/eshop.bicep | 2 +- .../eshop/iac/infra/aws-infra.bicep | 322 ++++++++++++++++++ reference-apps/eshop/iac/infra/aws.bicep | 269 +++------------ reference-apps/eshop/iac/infra/links.bicep | 2 +- .../infra/recipes/aws-memorydb-recipe.bicep | 49 +++ .../iac/infra/recipes/aws-mssql-recipe.bicep | 72 ++++ .../recipes/container-rabbitmq-recipe.bicep | 102 ++++++ .../eshop/iac/services/basket.bicep | 8 +- .../eshop/iac/services/catalog.bicep | 4 +- .../eshop/iac/services/identity.bicep | 4 +- .../eshop/iac/services/ordering.bicep | 10 +- .../eshop/iac/services/payment.bicep | 4 +- reference-apps/eshop/iac/services/web.bicep | 4 +- .../eshop/iac/services/webhooks.bicep | 4 +- .../eshop/iac/services/webshopping.bicep | 2 +- .../eshop/iac/services/webstatus.bicep | 2 +- 16 files changed, 613 insertions(+), 247 deletions(-) create mode 100644 reference-apps/eshop/iac/infra/aws-infra.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index aec6fb5b..a93b118b 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -279,7 +279,7 @@ module webshopping 'services/webshopping.bicep' = { } module webstatus 'services/webstatus.bicep' = { - name: 'websatatus' + name: 'webstatus' params: { application: eshop.id APPLICATION_INSIGHTS_KEY: APPLICATION_INSIGHTS_KEY diff --git a/reference-apps/eshop/iac/infra/aws-infra.bicep b/reference-apps/eshop/iac/infra/aws-infra.bicep new file mode 100644 index 00000000..d1e0d702 --- /dev/null +++ b/reference-apps/eshop/iac/infra/aws-infra.bicep @@ -0,0 +1,322 @@ +import radius as radius +import aws as aws + +@description('Radius environment ID') +param environment string + +@description('Radius application ID') +param application string + +@description('SQL administrator username') +param adminLogin string + +@description('SQL administrator password') +@secure() +param adminPassword string + +@description('Name of the EKS cluster where the application will be run. Used to setup subnet groups') +param eksClusterName string + +// Infrastructure ------------------------------------------------------------ + +resource eksCluster 'AWS.EKS/Cluster@default' existing = { + alias: eksClusterName + properties: { + Name: eksClusterName + } +} + +var sqlSubnetGroupName = 'eshopsqlsg${uniqueString(application)}' +resource sqlSubnetGroup 'AWS.RDS/DBSubnetGroup@default' = { + alias: sqlSubnetGroupName + properties: { + DBSubnetGroupName: sqlSubnetGroupName + DBSubnetGroupDescription: sqlSubnetGroupName + SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds + } +} + +var identityDbIdentifier = 'eshopidentitysql${uniqueString(application)}' +resource identityDb 'AWS.RDS/DBInstance@default' = { + alias: identityDbIdentifier + properties: { + DBInstanceIdentifier: identityDbIdentifier + Engine: 'sqlserver-ex' + EngineVersion: '15.00.4153.1.v1' + DBInstanceClass: 'db.t3.large' + AllocatedStorage: '20' + MaxAllocatedStorage: 30 + MasterUsername: adminLogin + MasterUserPassword: adminPassword + Port: '1433' + DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName + VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] + PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' + PreferredBackupWindow: '03:00-06:00' + LicenseModel: 'license-included' + Timezone: 'GMT Standard Time' + CharacterSetName: 'Latin1_General_CI_AS' + } +} + +var catalogDbIdentifier = 'eshopcatalogsql${uniqueString(application)}' +resource catalogDb 'AWS.RDS/DBInstance@default' = { + alias: catalogDbIdentifier + properties: { + DBInstanceIdentifier: catalogDbIdentifier + Engine: 'sqlserver-ex' + EngineVersion: '15.00.4153.1.v1' + DBInstanceClass: 'db.t3.large' + AllocatedStorage: '20' + MaxAllocatedStorage: 30 + MasterUsername: adminLogin + MasterUserPassword: adminPassword + Port: '1433' + DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName + VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] + PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' + PreferredBackupWindow: '03:00-06:00' + LicenseModel: 'license-included' + Timezone: 'GMT Standard Time' + CharacterSetName: 'Latin1_General_CI_AS' + } +} + +var orderingDbIdentifier = 'eshoporderingsql${uniqueString(application)}' +resource orderingDb 'AWS.RDS/DBInstance@default' = { + alias: orderingDbIdentifier + properties: { + DBInstanceIdentifier: orderingDbIdentifier + Engine: 'sqlserver-ex' + EngineVersion: '15.00.4153.1.v1' + DBInstanceClass: 'db.t3.large' + AllocatedStorage: '20' + MaxAllocatedStorage: 30 + MasterUsername: adminLogin + MasterUserPassword: adminPassword + Port: '1433' + DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName + VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] + PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' + PreferredBackupWindow: '03:00-06:00' + LicenseModel: 'license-included' + Timezone: 'GMT Standard Time' + CharacterSetName: 'Latin1_General_CI_AS' + } +} + +var webhooksDbIdentifier = 'eshopwebhookssql${uniqueString(application)}' +resource webhooksDb 'AWS.RDS/DBInstance@default' = { + alias: webhooksDbIdentifier + properties: { + DBInstanceIdentifier: webhooksDbIdentifier + Engine: 'sqlserver-ex' + EngineVersion: '15.00.4153.1.v1' + DBInstanceClass: 'db.t3.large' + AllocatedStorage: '20' + MaxAllocatedStorage: 30 + MasterUsername: adminLogin + MasterUserPassword: adminPassword + Port: '1433' + DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName + VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] + PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' + PreferredBackupWindow: '03:00-06:00' + LicenseModel: 'license-included' + Timezone: 'GMT Standard Time' + CharacterSetName: 'Latin1_General_CI_AS' + } +} + +var redisSubnetGroupName = 'eshopredissg${uniqueString(application)}' +resource redisSubnetGroup 'AWS.MemoryDB/SubnetGroup@default' = { + alias: redisSubnetGroupName + properties: { + SubnetGroupName: redisSubnetGroupName + SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds + } +} + +var keystoreCacheName = 'eshopkeystore${uniqueString(application)}' +resource keystoreCache 'AWS.MemoryDB/Cluster@default' = { + alias: keystoreCacheName + properties: { + ClusterName: keystoreCacheName + NodeType: 'db.t4g.small' + ACLName: 'open-access' + SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] + SubnetGroupName: redisSubnetGroup.properties.SubnetGroupName + NumReplicasPerShard: 0 + } +} + +var basketCacheName = 'eshopbasket${uniqueString(application)}' +resource basketCache 'AWS.MemoryDB/Cluster@default' = { + alias: basketCacheName + properties: { + ClusterName: basketCacheName + NodeType: 'db.t4g.small' + ACLName: 'open-access' + SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] + SubnetGroupName: redisSubnetGroup.name + NumReplicasPerShard: 0 + } +} + +// TEMP: Using containerized rabbitMQ instead of AWS SNS until AWS nonidempotency is resolved +resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'rabbitmq-container-eshop-event-bus' + properties: { + application: application + container: { + image: 'rabbitmq:3.9' + env: {} + ports: { + rabbitmq: { + containerPort: 5672 + provides: rabbitmqRoute.id + } + } + } + } +} + +resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'rabbitmq-route-eshop-event-bus' + properties: { + application: application + port: 5672 + } +} + +resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'identitydb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: 'IdentityDb' + server: identityDb.properties.Endpoint.Address + port: int(identityDb.properties.Endpoint.Port) + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${identityDb.properties.Endpoint.Address},${identityDb.properties.Endpoint.Port};Initial Catalog=IdentityDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'catalogdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: 'CatalogDb' + server: catalogDb.properties.Endpoint.Address + port: int(catalogDb.properties.Endpoint.Port) + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${catalogDb.properties.Endpoint.Address},${catalogDb.properties.Endpoint.Port};Initial Catalog=CatalogDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'orderingdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: 'OrderingDb' + server: orderingDb.properties.Endpoint.Address + port: int(orderingDb.properties.Endpoint.Port) + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${orderingDb.properties.Endpoint.Address},${orderingDb.properties.Endpoint.Port};Initial Catalog=OrderingDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'webhooksdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: 'WebhooksDb' + server: webhooksDb.properties.Endpoint.Address + port: int(webhooksDb.properties.Endpoint.Port) + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${webhooksDb.properties.Endpoint.Address},${webhooksDb.properties.Endpoint.Port};Initial Catalog=WebhooksDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + } +} + +resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'keystore-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: keystoreCache.properties.ClusterEndpoint.Address + port: keystoreCache.properties.ClusterEndpoint.Port + secrets: { + connectionString: '${keystoreCache.properties.ClusterEndpoint.Address}:${keystoreCache.properties.ClusterEndpoint.Port},ssl=true' + } + } +} + +resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'basket-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: basketCache.properties.ClusterEndpoint.Address + port: basketCache.properties.ClusterEndpoint.Port + secrets: { + connectionString: '${basketCache.properties.ClusterEndpoint.Address}:${basketCache.properties.ClusterEndpoint.Port},ssl=true' + } + } +} + +resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { + name: 'eshop-event-bus' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + queue: 'eshop-event-bus' + secrets: { + connectionString: rabbitmqRoute.properties.hostname + } + } +} + +// Outputs ------------------------------------ + +@description('The name of the SQL Identity Link') +output sqlIdentityDb string = sqlIdentityDb.name + +@description('The name of the SQL Catalog Link') +output sqlCatalogDb string = sqlCatalogDb.name + +@description('The name of the SQL Ordering Link') +output sqlOrderingDb string = sqlOrderingDb.name + +@description('The name of the SQL Webhooks Link') +output sqlWebhooksDb string = sqlWebhooksDb.name + +@description('The name of the Redis Keystore Link') +output redisKeystore string = redisKeystore.name + +@description('The name of the Redis Basket Link') +output redisBasket string = redisBasket.name + +@description('The name of the RabbitMQ Link') +output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/aws.bicep b/reference-apps/eshop/iac/infra/aws.bicep index 0c208a99..19c8db60 100644 --- a/reference-apps/eshop/iac/infra/aws.bicep +++ b/reference-apps/eshop/iac/infra/aws.bicep @@ -17,194 +17,19 @@ param adminPassword string @description('Name of the EKS cluster where the application will be run. Used to setup subnet groups') param eksClusterName string -// Infrastructure ------------------------------------------------------------ - -resource eksCluster 'AWS.EKS/Cluster@default' existing = { - alias: eksClusterName - properties: { - Name: eksClusterName - } -} - -var sqlSubnetGroupName = 'eshopsqlsg${uniqueString(application)}' -resource sqlSubnetGroup 'AWS.RDS/DBSubnetGroup@default' = { - alias: sqlSubnetGroupName - properties: { - DBSubnetGroupName: sqlSubnetGroupName - DBSubnetGroupDescription: sqlSubnetGroupName - SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds - } -} - -var identityDbIdentifier = 'eshopidentitysql${uniqueString(application)}' -resource identityDb 'AWS.RDS/DBInstance@default' = { - alias: identityDbIdentifier - properties: { - DBInstanceIdentifier: identityDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var catalogDbIdentifier = 'eshopcatalogsql${uniqueString(application)}' -resource catalogDb 'AWS.RDS/DBInstance@default' = { - alias: catalogDbIdentifier - properties: { - DBInstanceIdentifier: catalogDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var orderingDbIdentifier = 'eshoporderingsql${uniqueString(application)}' -resource orderingDb 'AWS.RDS/DBInstance@default' = { - alias: orderingDbIdentifier - properties: { - DBInstanceIdentifier: orderingDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var webhooksDbIdentifier = 'eshopwebhookssql${uniqueString(application)}' -resource webhooksDb 'AWS.RDS/DBInstance@default' = { - alias: webhooksDbIdentifier - properties: { - DBInstanceIdentifier: webhooksDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var redisSubnetGroupName = 'eshopredissg${uniqueString(application)}' -resource redisSubnetGroup 'AWS.MemoryDB/SubnetGroup@default' = { - alias: redisSubnetGroupName - properties: { - SubnetGroupName: redisSubnetGroupName - SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds - } -} - -var keystoreCacheName = 'eshopkeystore${uniqueString(application)}' -resource keystoreCache 'AWS.MemoryDB/Cluster@default' = { - alias: keystoreCacheName - properties: { - ClusterName: keystoreCacheName - NodeType: 'db.t4g.small' - ACLName: 'open-access' - SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] - SubnetGroupName: redisSubnetGroup.properties.SubnetGroupName - NumReplicasPerShard: 0 - } -} - -var basketCacheName = 'eshopbasket${uniqueString(application)}' -resource basketCache 'AWS.MemoryDB/Cluster@default' = { - alias: basketCacheName - properties: { - ClusterName: basketCacheName - NodeType: 'db.t4g.small' - ACLName: 'open-access' - SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] - SubnetGroupName: redisSubnetGroup.name - NumReplicasPerShard: 0 - } -} - -// TEMP: Using containerized rabbitMQ instead of AWS SNS until AWS nonidempotency is resolved -resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rabbitmq-container-eshop-event-bus' - properties: { - application: application - container: { - image: 'rabbitmq:3.9' - env: {} - ports: { - rabbitmq: { - containerPort: 5672 - provides: rabbitmqRoute.id - } - } - } - } -} - -resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'rabbitmq-route-eshop-event-bus' - properties: { - application: application - port: 5672 - } -} - -// Links ---------------------------------------------------------------------------- -// TODO: Move the Link definitions into the application and use Recipes instead - resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: 'IdentityDb' - server: identityDb.properties.Endpoint.Address - port: int(identityDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${identityDb.properties.Endpoint.Address},${identityDb.properties.Endpoint.Port};Initial Catalog=IdentityDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'aws-mssql' + parameters: { + eksClusterName: eksClusterName + database: 'IdentityDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -214,14 +39,14 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: 'CatalogDb' - server: catalogDb.properties.Endpoint.Address - port: int(catalogDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${catalogDb.properties.Endpoint.Address},${catalogDb.properties.Endpoint.Port};Initial Catalog=CatalogDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'aws-mssql' + parameters: { + eksClusterName: eksClusterName + database: 'CatalogDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -231,14 +56,14 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: 'OrderingDb' - server: orderingDb.properties.Endpoint.Address - port: int(orderingDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${orderingDb.properties.Endpoint.Address},${orderingDb.properties.Endpoint.Port};Initial Catalog=OrderingDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'aws-mssql' + parameters: { + eksClusterName: eksClusterName + database: 'OrderingDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -248,14 +73,14 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: 'WebhooksDb' - server: webhooksDb.properties.Endpoint.Address - port: int(webhooksDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${webhooksDb.properties.Endpoint.Address},${webhooksDb.properties.Endpoint.Port};Initial Catalog=WebhooksDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'aws-mssql' + parameters: { + eksClusterName: eksClusterName + database: 'WebhooksDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -265,11 +90,11 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: keystoreCache.properties.ClusterEndpoint.Address - port: keystoreCache.properties.ClusterEndpoint.Port - secrets: { - connectionString: '${keystoreCache.properties.ClusterEndpoint.Address}:${keystoreCache.properties.ClusterEndpoint.Port},ssl=true' + recipe: { + name: 'aws-memorydb' + parameters: { + eksClusterName: eksClusterName + } } } } @@ -279,30 +104,26 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: basketCache.properties.ClusterEndpoint.Address - port: basketCache.properties.ClusterEndpoint.Port - secrets: { - connectionString: '${basketCache.properties.ClusterEndpoint.Address}:${basketCache.properties.ClusterEndpoint.Port},ssl=true' + recipe: { + name: 'aws-memorydb' + parameters: { + eksClusterName: eksClusterName + } } } } -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { name: 'eshop-event-bus' properties: { application: application environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: rabbitmqRoute.properties.hostname + recipe: { + name: 'container-rabbitmq' } } } -// Outputs ------------------------------------ - @description('The name of the SQL Identity Link') output sqlIdentityDb string = sqlIdentityDb.name diff --git a/reference-apps/eshop/iac/infra/links.bicep b/reference-apps/eshop/iac/infra/links.bicep index f1685f07..55cbdd13 100644 --- a/reference-apps/eshop/iac/infra/links.bicep +++ b/reference-apps/eshop/iac/infra/links.bicep @@ -24,7 +24,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' e name: 'basket-data' } -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: 'eshop-event-bus' } diff --git a/reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep new file mode 100644 index 00000000..93c4fb14 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep @@ -0,0 +1,49 @@ +import aws as aws + +@description('Radius-provided object containing information about the resource calling the Recipe') +param context object + +@description('Name of the EKS cluster used for app deployment') +param eksClusterName string + +@description('List of subnetIds for the subnet group') +param subnetIds array = [] + +resource eksCluster 'AWS.EKS/Cluster@default' existing = { + alias: eksClusterName + properties: { + Name: eksClusterName + } +} + +param memoryDBSubnetGroupName string = 'eshop-memorydb-subnetgroup-${uniqueString(context.resource.id)}' +resource subnetGroup 'AWS.MemoryDB/SubnetGroup@default' = { + alias: memoryDBSubnetGroupName + properties: { + SubnetGroupName: memoryDBSubnetGroupName + SubnetIds: ((empty(subnetIds)) ? eksCluster.properties.ResourcesVpcConfig.SubnetIds : concat(subnetIds,eksCluster.properties.ResourcesVpcConfig.SubnetIds)) + } +} + +param memoryDBClusterName string = 'eshop-memorydb-cluster-${uniqueString(context.resource.id)}' +resource memoryDBCluster 'AWS.MemoryDB/Cluster@default' = { + alias: memoryDBClusterName + properties: { + ClusterName: memoryDBClusterName + NodeType: 'db.t4g.small' + ACLName: 'open-access' + SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] + SubnetGroupName: subnetGroup.name + NumReplicasPerShard: 0 + } +} + +output result object = { + values: { + host: memoryDBCluster.properties.ClusterEndpoint.Address + port: memoryDBCluster.properties.ClusterEndpoint.Port + } + secrets: { + url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port},ssl=true' + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep new file mode 100644 index 00000000..a6f54843 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep @@ -0,0 +1,72 @@ +import aws as aws + +@description('Radius-provided object containing information about the resource calling the Recipe') +param context object + +@description('Name of the EKS cluster used for app deployment') +param eksClusterName string + +@description('SQL administrator username') +param adminLogin string + +@description('SQL administrator password') +@secure() +param adminPassword string + +@description('Database name') +param database string + +resource eksCluster 'AWS.EKS/Cluster@default' existing = { + alias: eksClusterName + properties: { + Name: eksClusterName + } +} + +var rdsSubnetGroupName = 'eshop-rds-dbsubnetgroup-${uniqueString(context.resource.id)}' +resource rdsDBSubnetGroup 'AWS.RDS/DBSubnetGroup@default' = { + alias: rdsSubnetGroupName + properties: { + DBSubnetGroupName: rdsSubnetGroupName + DBSubnetGroupDescription: rdsSubnetGroupName + SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds + } +} + +var rdsDBInstanceName = 'eshop-rds-dbinstance-${uniqueString(context.resource.id)}' +resource rdsDBInstance 'AWS.RDS/DBInstance@default' = { + alias: rdsDBInstanceName + properties: { + DBInstanceIdentifier: rdsDBInstanceName + Engine: 'sqlserver-ex' + EngineVersion: '15.00.4153.1.v1' + DBInstanceClass: 'db.t3.large' + AllocatedStorage: '20' + MaxAllocatedStorage: 30 + MasterUsername: adminLogin + MasterUserPassword: adminPassword + // Port: '1433' + DBSubnetGroupName: rdsDBSubnetGroup.properties.DBSubnetGroupName + VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] + PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' + PreferredBackupWindow: '03:00-06:00' + LicenseModel: 'license-included' + Timezone: 'GMT Standard Time' + CharacterSetName: 'Latin1_General_CI_AS' + } +} + +output result object = { + values: { + server: rdsDBInstance.properties.Endpoint.Address + port: 1433 + database: database + username: adminLogin + } + secrets: { + #disable-next-line outputs-should-not-contain-secrets + connectionString: 'Server=tcp:${rdsDBInstance.properties.Endpoint.Address},${rdsDBInstance.properties.Endpoint.Port};Initial Catalog=${database};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + #disable-next-line outputs-should-not-contain-secrets + password: adminPassword + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep new file mode 100644 index 00000000..eb94de83 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep @@ -0,0 +1,102 @@ +@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') +param context object + +@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') +param queue string = context.resource.name + +@description('Tag to pull for the rabbitmq container image.') +param tag string = '3' + +@description('Memory request for the rabbitmq deployment.') +param memoryRequest string = '256Mi' + +@description('Memory limit for the rabbitmq deployment') +param memoryLimit string = '1024Mi' + +import kubernetes as kubernetes { + kubeConfig: '' + namespace: context.runtime.kubernetes.namespace +} + +var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' +var port = 5672 + +resource rabbitmq 'apps/Deployment@v1' = { + metadata: { + name: uniqueName + } + spec: { + selector: { + matchLabels: { + app: 'rabbitmq' + resource: context.resource.name + } + } + template: { + metadata: { + labels: { + app: 'rabbitmq' + resource: context.resource.name + // Label pods with the application name so `rad run` can find the logs. + 'radius.dev/application': context.application == null ? '' : context.application.name + } + } + spec: { + containers: [ + { + name: 'rabbitmq' + image: 'rabbitmq:${tag}' + ports: [ + { + containerPort: port + } + ] + resources: { + requests: { + memory: memoryRequest + } + limits: { + memory: memoryLimit + } + } + env: [] + } + ] + } + } + } +} + +resource svc 'core/Service@v1' = { + metadata: { + name: uniqueName + labels: { + name: uniqueName + } + } + spec: { + type: 'ClusterIP' + selector: { + app: 'rabbitmq' + resource: context.resource.name + } + ports: [ + { + port: port + } + ] + } +} + +output result object = { + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' + ] + values: { + queue: queue + } + secrets: { + connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + } +} diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index 6edcf478..303731fa 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -5,7 +5,7 @@ import radius as rad @description('Radius application ID') param application string -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Optional App Insights Key') @@ -65,8 +65,8 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { PORT: '80' GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - ConnectionString: redisBasket.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + ConnectionString: '${redisBasket.connectionString()},ssl=true' + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -118,6 +118,6 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' e name: redisBasketName } -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index 930f8866..c4c71058 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -74,7 +74,7 @@ resource catalog 'Applications.Core/containers@2022-03-15-privatepreview' = { ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlCatalogDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') } ports: { http: { @@ -115,6 +115,6 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' name: sqlCatalogDbName } -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/identity.bicep b/reference-apps/eshop/iac/services/identity.bicep index a4cd2c4a..256d550a 100644 --- a/reference-apps/eshop/iac/services/identity.bicep +++ b/reference-apps/eshop/iac/services/identity.bicep @@ -15,7 +15,7 @@ param APPLICATION_INSIGHTS_KEY string ]) param ENABLEDEVSPACES string -@description('Cotnainer image tag to use for eshop images. Defaults to linux-dotnet7') +@description('Container image tag to use for eshop images. Defaults to linux-dotnet7') param TAG string @description('Name of the Gateway') @@ -63,7 +63,7 @@ resource identity 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' OrchestratorType: 'K8S' IsClusterEnv: 'True' - DPConnectionString: redisKeystore.connectionString() + DPConnectionString: '${redisKeystore.connectionString()},ssl=true' ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY XamarinCallback: '' EnableDevspaces: ENABLEDEVSPACES diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index dbeef5ea..01c3497c 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -85,7 +85,7 @@ resource ordering 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' PORT: '80' ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -132,7 +132,7 @@ resource orderbgtasks 'Applications.Core/containers@2022-03-15-privatepreview' = OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') } ports: { http: { @@ -165,8 +165,8 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() - SignalrStoreConnectionString: '${redisKeystore.properties.host}:${redisKeystore.properties.port},password=${redisKeystore.password()},abortConnect=False' + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + SignalrStoreConnectionString: '${redisKeystore.connectionString()},ssl=true' identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -246,6 +246,6 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview name: sqlOrderingDbName } -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/payment.bicep b/reference-apps/eshop/iac/services/payment.bicep index 372aa5b2..e4e55f89 100644 --- a/reference-apps/eshop/iac/services/payment.bicep +++ b/reference-apps/eshop/iac/services/payment.bicep @@ -49,7 +49,7 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { 'Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ': 'Verbose' OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') } ports: { http: { @@ -69,6 +69,6 @@ resource paymentHttp 'Applications.Core/httpRoutes@2022-03-15-privatepreview' ex // LINKS ----------------------------------------------------------- -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/web.bicep b/reference-apps/eshop/iac/services/web.bicep index 895ab74e..35ea1b3b 100644 --- a/reference-apps/eshop/iac/services/web.bicep +++ b/reference-apps/eshop/iac/services/web.bicep @@ -59,7 +59,7 @@ resource webspa 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' CallBackUrl: '${gateway.properties.url}/' - DPConnectionString: redisKeystore.connectionString() + DPConnectionString: '${redisKeystore.connectionString()},ssl=true' IdentityUrl: '${gateway.properties.url}/identity-api' IdentityUrlHC: '${identityHttp.properties.url}/hc' PurchaseUrl: '${gateway.properties.url}/webshoppingapigw' @@ -109,7 +109,7 @@ resource webmvc 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' PATH_BASE: '/webmvc' UseCustomizationData: 'False' - DPConnectionString: redisKeystore.connectionString() + DPConnectionString: '${redisKeystore.connectionString()},ssl=true' ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY UseLoadTest: 'False' OrchestratorType: ORCHESTRATOR_TYPE diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 4cd71ad0..581aedce 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -59,7 +59,7 @@ resource webhooks 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlWebhooksDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.connectionString() + EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -143,6 +143,6 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview name: sqlWebhooksDbName } -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/webshopping.bicep b/reference-apps/eshop/iac/services/webshopping.bicep index ad9d80e0..d3526dbb 100644 --- a/reference-apps/eshop/iac/services/webshopping.bicep +++ b/reference-apps/eshop/iac/services/webshopping.bicep @@ -186,6 +186,6 @@ resource webshoppingapigwHttp2 'Applications.Core/httpRoutes@2022-03-15-privatep // LINKS -------------------------------------------------------- -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' existing = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { name: rabbitmqName } diff --git a/reference-apps/eshop/iac/services/webstatus.bicep b/reference-apps/eshop/iac/services/webstatus.bicep index 36877715..e1e9cf9e 100644 --- a/reference-apps/eshop/iac/services/webstatus.bicep +++ b/reference-apps/eshop/iac/services/webstatus.bicep @@ -14,7 +14,7 @@ param ORCHESTRATOR_TYPE string @description('Optional App Insights Key') param APPLICATION_INSIGHTS_KEY string -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Basket Http Route name') From 7daf9cbe8bc7fffbebd035136b46cd937039cc1d Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Wed, 12 Jul 2023 18:15:58 -0700 Subject: [PATCH 02/12] Container recipes working --- .../eshop/iac/aws-environment.bicep | 52 +++ .../eshop/iac/azure-environment.bicep | 43 ++ .../eshop/iac/containers-environment.bicep | 32 ++ reference-apps/eshop/iac/eshop.bicep | 22 +- .../eshop/iac/infra/aws-infra.bicep | 4 +- reference-apps/eshop/iac/infra/aws.bicep | 29 +- .../eshop/iac/infra/azure-infra.bicep | 395 ++++++++++++++++++ reference-apps/eshop/iac/infra/azure.bicep | 357 +++------------- .../eshop/iac/infra/containers-infra.bicep | 340 +++++++++++++++ .../eshop/iac/infra/containers.bicep | 300 +++---------- reference-apps/eshop/iac/infra/links.bicep | 2 +- .../awsmssql.bicep} | 0 .../awsredis.bicep} | 2 +- .../iac/infra/recipes/azure/azuremssql.bicep | 74 ++++ .../iac/infra/recipes/azure/azureredis.bicep | 49 +++ .../recipes/containers/containersmssql.bicep | 129 ++++++ .../containersrabbitmq.bicep} | 0 .../recipes/containers/containersredis.bicep | 93 +++++ .../eshop/iac/services/basket.bicep | 22 +- .../eshop/iac/services/catalog.bicep | 11 +- .../eshop/iac/services/identity.bicep | 2 +- .../eshop/iac/services/ordering.bicep | 16 +- .../eshop/iac/services/payment.bicep | 10 +- reference-apps/eshop/iac/services/web.bicep | 6 +- .../eshop/iac/services/webhooks.bicep | 10 +- .../eshop/iac/services/webshopping.bicep | 2 +- 26 files changed, 1354 insertions(+), 648 deletions(-) create mode 100644 reference-apps/eshop/iac/aws-environment.bicep create mode 100644 reference-apps/eshop/iac/azure-environment.bicep create mode 100644 reference-apps/eshop/iac/containers-environment.bicep create mode 100644 reference-apps/eshop/iac/infra/azure-infra.bicep create mode 100644 reference-apps/eshop/iac/infra/containers-infra.bicep rename reference-apps/eshop/iac/infra/recipes/{aws-mssql-recipe.bicep => aws/awsmssql.bicep} (100%) rename reference-apps/eshop/iac/infra/recipes/{aws-memorydb-recipe.bicep => aws/awsredis.bicep} (96%) create mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep rename reference-apps/eshop/iac/infra/recipes/{container-rabbitmq-recipe.bicep => containers/containersrabbitmq.bicep} (100%) create mode 100644 reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep diff --git a/reference-apps/eshop/iac/aws-environment.bicep b/reference-apps/eshop/iac/aws-environment.bicep new file mode 100644 index 00000000..989a2d5d --- /dev/null +++ b/reference-apps/eshop/iac/aws-environment.bicep @@ -0,0 +1,52 @@ +import radius as rad + +@description('Account ID of the AWS account resources should be deployed in') +param awsAccountId string + +@description('AWS region that resources should be deployed in') +param awsRegion string + +@description('Name of your EKS cluster') +param eksClusterName string + +resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = { + name: 'aws-eshop-env' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'eshop' + } + providers: { + aws: { + scope: '/planes/aws/aws/accounts/${awsAccountId}/regions/${awsRegion}' + } + } + recipes: { + 'Applications.Link/sqlDatabases': { + awsmssql: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/awsmssql:edge' + parameters: { + eksClusterName: eksClusterName + } + } + } + 'Applications.Link/redisCaches': { + awsredis: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/awsredis:edge' + parameters: { + eksClusterName: eksClusterName + } + } + } + 'Applications.Link/extenders': { + containersrabbitmq: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + } + } + } + } +} diff --git a/reference-apps/eshop/iac/azure-environment.bicep b/reference-apps/eshop/iac/azure-environment.bicep new file mode 100644 index 00000000..db41fbf7 --- /dev/null +++ b/reference-apps/eshop/iac/azure-environment.bicep @@ -0,0 +1,43 @@ +import radius as rad + +@description('Azure ResourceGroup name') +param azureResourceGroup string = resourceGroup().name + +@description('Azure SubscriptionId') +param azureSubscription string = subscription().subscriptionId + +resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = { + name: 'azure-eshop-env' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'eshop' + } + providers: { + azure: { + scope: '/subscriptions/${azureSubscription}/resourceGroups/${azureResourceGroup}' + } + } + recipes: { + 'Applications.Link/sqlDatabases': { + azuremssql: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/azuremssql:edge' + } + } + 'Applications.Link/redisCaches': { + azureredis: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/azureredis:edge' + } + } + 'Applications.Link/extenders': { + containersmessagequeue: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + } + } + } + } +} diff --git a/reference-apps/eshop/iac/containers-environment.bicep b/reference-apps/eshop/iac/containers-environment.bicep new file mode 100644 index 00000000..93fe4fd8 --- /dev/null +++ b/reference-apps/eshop/iac/containers-environment.bicep @@ -0,0 +1,32 @@ +import radius as rad + +resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview' = { + name: 'containers-eshop-env' + properties: { + compute: { + kind: 'kubernetes' + resourceId: 'self' + namespace: 'eshop' + } + recipes: { + 'Applications.Link/sqlDatabases': { + containersmssql: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/containersmssql:edge' + } + } + 'Applications.Link/redisCaches': { + containersredis: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/containersredis:edge' + } + } + 'Applications.Link/extenders': { + containersrabbitmq: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + } + } + } + } +} diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index a93b118b..8bbf72e8 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -1,6 +1,6 @@ import radius as rad -// Paramaters ------------------------------------------------------- +// Parameters ------------------------------------------------------- @description('Name of the eshop application. Defaults to "eshop"') param appName string = 'eshop' @@ -39,7 +39,12 @@ param APPLICATION_INSIGHTS_KEY string = '' ]) param AZURESTORAGEENABLED string = 'False' -var AZURESERVICEBUSENABLED = (platform == 'azure') ? 'True' : 'False' +@description('Use Azure Service Bus for messaging') +@allowed([ + 'True' + 'False' +]) +param AZURESERVICEBUSENABLED string = 'False' @description('Use dev spaces. Defaults to False') @allowed([ @@ -48,12 +53,9 @@ var AZURESERVICEBUSENABLED = (platform == 'azure') ? 'True' : 'False' ]) param ENABLEDEVSPACES string = 'False' -@description('Cotnainer image tag to use for eshop images. Defaults to linux-dotnet7') +@description('Container image tag to use for eshop images. Defaults to linux-dotnet7') param TAG string = 'linux-dotnet7' -@description('Name of your EKS cluster. Only used if deploying with AWS infrastructure.') -param eksClusterName string = '' - // Application -------------------------------------------------------- resource eshop 'Applications.Core/applications@2022-03-15-privatepreview' = { @@ -70,6 +72,7 @@ module containers 'infra/containers.bicep' = if (platform == 'containers') { params: { application: eshop.id environment: environment + adminLogin: adminLogin adminPassword: adminPassword } } @@ -90,7 +93,6 @@ module aws 'infra/aws.bicep' = if (platform == 'aws') { name: 'aws' params: { application: eshop.id - eksClusterName: eksClusterName environment: environment adminLogin: adminLogin adminPassword: adminPassword @@ -98,7 +100,6 @@ module aws 'infra/aws.bicep' = if (platform == 'aws') { } // Links ----------------------------------------------------------- -// TODO: Switch to Recipes once ready module links 'infra/links.bicep' = { name: 'links' @@ -134,7 +135,6 @@ module basket 'services/basket.bicep' = { rabbitmqName: links.outputs.rabbitmq redisBasketName: links.outputs.redisBasket TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? azure.outputs.serviceBusAuthConnectionString : '' } } @@ -152,7 +152,6 @@ module catalog 'services/catalog.bicep' = { rabbitmqName: links.outputs.rabbitmq sqlCatalogDbName: links.outputs.sqlCatalogDb TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? azure.outputs.serviceBusAuthConnectionString : '' } } @@ -195,7 +194,6 @@ module ordering 'services/ordering.bicep' = { redisKeystoreName: links.outputs.redisKeystore sqlOrderingDbName: links.outputs.sqlOrderingDb TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? azure.outputs.serviceBusAuthConnectionString : '' } } @@ -209,7 +207,6 @@ module payment 'services/payment.bicep' = { paymentHttpName: networking.outputs.paymentHttp rabbitmqName: links.outputs.rabbitmq TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? azure.outputs.serviceBusAuthConnectionString : '' } } @@ -252,7 +249,6 @@ module webhooks 'services/webhooks.bicep' = { TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? azure.outputs.serviceBusAuthConnectionString : '' } } diff --git a/reference-apps/eshop/iac/infra/aws-infra.bicep b/reference-apps/eshop/iac/infra/aws-infra.bicep index d1e0d702..f8b93814 100644 --- a/reference-apps/eshop/iac/infra/aws-infra.bicep +++ b/reference-apps/eshop/iac/infra/aws-infra.bicep @@ -266,7 +266,7 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' host: keystoreCache.properties.ClusterEndpoint.Address port: keystoreCache.properties.ClusterEndpoint.Port secrets: { - connectionString: '${keystoreCache.properties.ClusterEndpoint.Address}:${keystoreCache.properties.ClusterEndpoint.Port},ssl=true' + connectionString: '${keystoreCache.properties.ClusterEndpoint.Address}:${keystoreCache.properties.ClusterEndpoint.Port}' } } } @@ -280,7 +280,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = host: basketCache.properties.ClusterEndpoint.Address port: basketCache.properties.ClusterEndpoint.Port secrets: { - connectionString: '${basketCache.properties.ClusterEndpoint.Address}:${basketCache.properties.ClusterEndpoint.Port},ssl=true' + connectionString: '${basketCache.properties.ClusterEndpoint.Address}:${basketCache.properties.ClusterEndpoint.Port}' } } } diff --git a/reference-apps/eshop/iac/infra/aws.bicep b/reference-apps/eshop/iac/infra/aws.bicep index 19c8db60..70b6fb5b 100644 --- a/reference-apps/eshop/iac/infra/aws.bicep +++ b/reference-apps/eshop/iac/infra/aws.bicep @@ -14,18 +14,14 @@ param adminLogin string @secure() param adminPassword string -@description('Name of the EKS cluster where the application will be run. Used to setup subnet groups') -param eksClusterName string - resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' properties: { application: application environment: environment recipe: { - name: 'aws-mssql' + name: 'awsmssql' parameters: { - eksClusterName: eksClusterName database: 'IdentityDb' adminLogin: adminLogin adminPassword: adminPassword @@ -40,9 +36,8 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: 'aws-mssql' + name: 'awsmssql' parameters: { - eksClusterName: eksClusterName database: 'CatalogDb' adminLogin: adminLogin adminPassword: adminPassword @@ -57,9 +52,8 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: 'aws-mssql' + name: 'awsmssql' parameters: { - eksClusterName: eksClusterName database: 'OrderingDb' adminLogin: adminLogin adminPassword: adminPassword @@ -74,9 +68,8 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: 'aws-mssql' + name: 'awsmssql' parameters: { - eksClusterName: eksClusterName database: 'WebhooksDb' adminLogin: adminLogin adminPassword: adminPassword @@ -91,10 +84,7 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: 'aws-memorydb' - parameters: { - eksClusterName: eksClusterName - } + name: 'awsredis' } } } @@ -105,21 +95,18 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = application: application environment: environment recipe: { - name: 'aws-memorydb' - parameters: { - eksClusterName: eksClusterName - } + name: 'awsredis' } } } resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' + name: 'rabbitmq' properties: { application: application environment: environment recipe: { - name: 'container-rabbitmq' + name: 'containersrabbitmq' } } } diff --git a/reference-apps/eshop/iac/infra/azure-infra.bicep b/reference-apps/eshop/iac/infra/azure-infra.bicep new file mode 100644 index 00000000..5472e9a3 --- /dev/null +++ b/reference-apps/eshop/iac/infra/azure-infra.bicep @@ -0,0 +1,395 @@ +import radius as rad +import az as az + +@description('Azure region to deploy resources into') +param location string = resourceGroup().location + +@description('Radius environment ID') +param environment string + +@description('Radius application ID') +param application string + +@description('SQL administrator username') +param adminLogin string + +@description('SQL administrator password') +@secure() +param adminPassword string + +var sqlPort = 1433 + +// Infrastructure ------------------------------------------------------------ +// TODO: Move the infrastructure into Recipes + +resource servicebus 'Microsoft.ServiceBus/namespaces@2021-06-01-preview' = { + name: 'eshop${uniqueString(resourceGroup().id)}' + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + + resource topic 'topics' = { + name: 'eshop_event_bus' + properties: { + defaultMessageTimeToLive: 'P14D' + maxSizeInMegabytes: 1024 + requiresDuplicateDetection: false + enableBatchedOperations: true + supportOrdering: false + enablePartitioning: true + enableExpress: false + } + + resource rootRule 'authorizationRules' = { + name: 'Root' + properties: { + rights: [ + 'Manage' + 'Send' + 'Listen' + ] + } + } + + resource basket 'subscriptions' = { + name: 'Basket' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource catalog 'subscriptions' = { + name: 'Catalog' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource ordering 'subscriptions' = { + name: 'Ordering' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource graceperiod 'subscriptions' = { + name: 'GracePeriod' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource payment 'subscriptions' = { + name: 'Payment' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource backgroundTasks 'subscriptions' = { + name: 'backgroundtasks' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource OrderingSignalrHub 'subscriptions' = { + name: 'Ordering.signalrhub' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + + resource webhooks 'subscriptions' = { + name: 'Webhooks' + properties: { + requiresSession: false + defaultMessageTimeToLive: 'P14D' + deadLetteringOnMessageExpiration: true + deadLetteringOnFilterEvaluationExceptions: true + maxDeliveryCount: 10 + enableBatchedOperations: true + } + } + } +} + +resource sql 'Microsoft.Sql/servers@2021-02-01-preview' = { + name: 'eshopsql${uniqueString(resourceGroup().id)}' + location: location + properties: { + administratorLogin: adminLogin + administratorLoginPassword: adminPassword + } + + resource allowEverything 'firewallRules' = { + name: 'allow-everrything' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '255.255.255.255' + } + } + + resource identityDb 'databases' = { + name: 'IdentityDb' + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + } + + resource catalogDb 'databases' = { + name: 'CatalogDb' + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + } + + resource orderingDb 'databases' = { + name: 'OrderingDb' + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + } + + resource webhooksDb 'databases' = { + name: 'WebhooksDb' + location: location + sku: { + name: 'Standard' + tier: 'Standard' + } + } +} + +resource keystoreCache 'Microsoft.Cache/redis@2020-12-01' = { + name: 'eshopkeystore${uniqueString(resourceGroup().id)}' + location: location + properties: { + enableNonSslPort: false + minimumTlsVersion: '1.2' + sku: { + family: 'C' + capacity: 1 + name: 'Basic' + } + } +} + +resource basketCache 'Microsoft.Cache/redis@2020-12-01' = { + name: 'eshopbasket${uniqueString(resourceGroup().id)}' + location: location + properties: { + enableNonSslPort: false + minimumTlsVersion: '1.2' + sku: { + family: 'C' + capacity: 1 + name: 'Basic' + } + } +} + +// Links ---------------------------------------------------------------------------- +// TODO: Move the Link definitions into the application and use Recipes instead + +// Need to deploy a blank rabbitmq instance to let Bicep successfully deploy +resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { + name: 'eshop-event-bus' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + queue: 'eshop-event-bus' + secrets: { + connectionString: 'test' + } + } +} + +resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'identitydb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: sql::identityDb.name + server: sql.properties.fullyQualifiedDomainName + port: sqlPort + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::identityDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + resources: [ + { + id: sql::identityDb.id + } + ] + } +} + +resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'catalogdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: sql::catalogDb.name + server: sql.properties.fullyQualifiedDomainName + port: sqlPort + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::catalogDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + resources: [ + { + id: sql::catalogDb.id + } + ] + } +} + +resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'orderingdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: sql::orderingDb.name + server: sql.properties.fullyQualifiedDomainName + port: sqlPort + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::orderingDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + resources: [ + { + id: sql::orderingDb.id + } + ] + } +} + +resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'webhooksdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + database: sql::webhooksDb.name + server: sql.properties.fullyQualifiedDomainName + port: sqlPort + username: adminLogin + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::webhooksDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } + resources: [ + { + id: sql::webhooksDb.id + } + ] + } +} + +resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'basket-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: basketCache.properties.hostName + port: basketCache.properties.sslPort + secrets: { + password: basketCache.listKeys().primaryKey + connectionString: '${basketCache.properties.hostName}:${basketCache.properties.sslPort},password=${basketCache.listKeys().primaryKey},abortConnect=False' + } + } +} + +resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'keystore-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: keystoreCache.properties.hostName + port: keystoreCache.properties.sslPort + secrets: { + password: keystoreCache.listKeys().primaryKey + connectionString: '${keystoreCache.properties.hostName}:${keystoreCache.properties.sslPort},password=${keystoreCache.listKeys().primaryKey},abortConnect=False' + } + } +} + +// Outputs ------------------------------------ + +@description('The ID of the auth rule') +#disable-next-line outputs-should-not-contain-secrets +output serviceBusAuthConnectionString string = servicebus::topic::rootRule.listKeys().primaryConnectionString + +@description('The name of the RabbitMQ Queue') +output rabbitMqQueue string = rabbitmq.name + +@description('The name of the SQL Identity Link') +output sqlIdentityDb string = sqlIdentityDb.name + +@description('The name of the SQL Catalog Link') +output sqlCatalogDb string = sqlCatalogDb.name + +@description('The name of the SQL Ordering Link') +output sqlOrderingDb string = sqlOrderingDb.name + +@description('The name of the SQL Webhooks Link') +output sqlWebhooksDb string = sqlWebhooksDb.name + +@description('The name of the Redis Keystore Link') +output redisKeystore string = redisKeystore.name + +@description('The name of the Redis Basket Link') +output redisBasket string = redisBasket.name diff --git a/reference-apps/eshop/iac/infra/azure.bicep b/reference-apps/eshop/iac/infra/azure.bicep index fc1fe5e2..f8778f4a 100644 --- a/reference-apps/eshop/iac/infra/azure.bicep +++ b/reference-apps/eshop/iac/infra/azure.bicep @@ -1,9 +1,6 @@ import radius as rad import az as az -@description('Azure region to deploy resources into') -param location string = resourceGroup().location - @description('Radius environment ID') param environment string @@ -17,260 +14,21 @@ param adminLogin string @secure() param adminPassword string -var sqlPort = 1433 - -// Infrastructure ------------------------------------------------------------ -// TODO: Move the infrastructure into Recipes - -resource servicebus 'Microsoft.ServiceBus/namespaces@2021-06-01-preview' = { - name: 'eshop${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - - resource topic 'topics' = { - name: 'eshop_event_bus' - properties: { - defaultMessageTimeToLive: 'P14D' - maxSizeInMegabytes: 1024 - requiresDuplicateDetection: false - enableBatchedOperations: true - supportOrdering: false - enablePartitioning: true - enableExpress: false - } - - resource rootRule 'authorizationRules' = { - name: 'Root' - properties: { - rights: [ - 'Manage' - 'Send' - 'Listen' - ] - } - } - - resource basket 'subscriptions' = { - name: 'Basket' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource catalog 'subscriptions' = { - name: 'Catalog' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource ordering 'subscriptions' = { - name: 'Ordering' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource graceperiod 'subscriptions' = { - name: 'GracePeriod' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource payment 'subscriptions' = { - name: 'Payment' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource backgroundTasks 'subscriptions' = { - name: 'backgroundtasks' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource OrderingSignalrHub 'subscriptions' = { - name: 'Ordering.signalrhub' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource webhooks 'subscriptions' = { - name: 'Webhooks' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - } - -} - -resource sql 'Microsoft.Sql/servers@2021-02-01-preview' = { - name: 'eshopsql${uniqueString(resourceGroup().id)}' - location: location - properties: { - administratorLogin: adminLogin - administratorLoginPassword: adminPassword - } - - resource allowEverything 'firewallRules' = { - name: 'allow-everrything' - properties: { - startIpAddress: '0.0.0.0' - endIpAddress: '255.255.255.255' - } - } - - resource identityDb 'databases' = { - name: 'IdentityDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource catalogDb 'databases' = { - name: 'CatalogDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource orderingDb 'databases' = { - name: 'OrderingDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource webhooksDb 'databases' = { - name: 'WebhooksDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - -} - -resource keystoreCache 'Microsoft.Cache/redis@2020-12-01' = { - name: 'eshopkeystore${uniqueString(resourceGroup().id)}' - location: location - properties: { - enableNonSslPort: false - minimumTlsVersion: '1.2' - sku: { - family: 'C' - capacity: 1 - name: 'Basic' - } - } -} - -resource basketCache 'Microsoft.Cache/redis@2020-12-01' = { - name: 'eshopbasket${uniqueString(resourceGroup().id)}' - location: location - properties: { - enableNonSslPort: false - minimumTlsVersion: '1.2' - sku: { - family: 'C' - capacity: 1 - name: 'Basic' - } - } -} - // Links ---------------------------------------------------------------------------- -// TODO: Move the Link definitions into the application and use Recipes instead - -// Need to deploy a blank rabbitmq instance to let Bicep successfully deploy -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: 'test' - } - } -} resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: sql::identityDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::identityDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::identityDb.id + recipe: { + name: 'azuremssql' + parameters: { + database: 'IdentityDb' + adminLogin: adminLogin + adminPassword: adminPassword } - ] + } } } @@ -279,20 +37,14 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: sql::catalogDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::catalogDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::catalogDb.id + recipe: { + name: 'azuremssql' + parameters: { + database: 'CatalogDb' + adminLogin: adminLogin + adminPassword: adminPassword } - ] + } } } @@ -301,20 +53,14 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: sql::orderingDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::orderingDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::orderingDb.id + recipe: { + name: 'azuremssql' + parameters: { + database: 'OrderingDb' + adminLogin: adminLogin + adminPassword: adminPassword } - ] + } } } @@ -323,20 +69,25 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - database: sql::webhooksDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::webhooksDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::webhooksDb.id + recipe: { + name: 'azuremssql' + parameters: { + database: 'WebhooksDb' + adminLogin: adminLogin + adminPassword: adminPassword } - ] + } + } +} + +resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'keystore-data' + properties: { + application: application + environment: environment + recipe: { + name: 'azureredis' + } } } @@ -345,40 +96,25 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: basketCache.properties.hostName - port: basketCache.properties.sslPort - secrets: { - password: basketCache.listKeys().primaryKey - connectionString: '${basketCache.properties.hostName}:${basketCache.properties.sslPort},password=${basketCache.listKeys().primaryKey},ssl=True,abortConnect=False' + recipe: { + name: 'azureredis' } } } -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { + name: 'rabbitmq' properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: keystoreCache.properties.hostName - port: keystoreCache.properties.sslPort - secrets: { - password: keystoreCache.listKeys().primaryKey - connectionString: '${keystoreCache.properties.hostName}:${keystoreCache.properties.sslPort},password=${keystoreCache.listKeys().primaryKey},ssl=True,abortConnect=False' + recipe: { + name: 'containersrabbitmq' } } } // Outputs ------------------------------------ -@description('The ID of the auth rule') -#disable-next-line outputs-should-not-contain-secrets -output serviceBusAuthConnectionString string = servicebus::topic::rootRule.listKeys().primaryConnectionString - -@description('The name of the RabbitMQ Queue') -output rabbitMqQueue string = rabbitmq.name - @description('The name of the SQL Identity Link') output sqlIdentityDb string = sqlIdentityDb.name @@ -396,3 +132,6 @@ output redisKeystore string = redisKeystore.name @description('The name of the Redis Basket Link') output redisBasket string = redisBasket.name + +@description('The name of the RabbitMQ Link') +output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/containers-infra.bicep b/reference-apps/eshop/iac/infra/containers-infra.bicep new file mode 100644 index 00000000..52c493f5 --- /dev/null +++ b/reference-apps/eshop/iac/infra/containers-infra.bicep @@ -0,0 +1,340 @@ +import radius as rad + +@description('Radius environment ID') +param environment string + +@description('Radius application ID') +param application string + +@description('SQL administrator password') +@secure() +param adminPassword string + +var adminUsername = 'sa' + +// Infrastructure ------------------------------------------------- + +resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'rabbitmq-container-eshop-event-bus' + properties: { + application: application + container: { + image: 'rabbitmq:3.9' + env: {} + ports: { + rabbitmq: { + containerPort: 5672 + provides: rabbitmqRoute.id + } + } + } + } +} + +resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'rabbitmq-route-eshop-event-bus' + properties: { + application: application + port: 5672 + } +} + +resource sqlIdentityContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'sql-server-identitydb' + properties: { + application: application + container: { + image: 'mcr.microsoft.com/mssql/server:2019-latest' + env: { + ACCEPT_EULA: 'Y' + MSSQL_PID: 'Developer' + MSSQL_SA_PASSWORD: adminPassword + } + ports: { + sql: { + containerPort: 1433 + provides: sqlIdentityRoute.id + } + } + } + } +} + +resource sqlIdentityRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'sql-route-identitydb' + properties: { + application: application + port: 1433 + } +} + +resource sqlCatalogContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'sql-server-catalogdb' + properties: { + application: application + container: { + image: 'mcr.microsoft.com/mssql/server:2019-latest' + env: { + ACCEPT_EULA: 'Y' + MSSQL_PID: 'Developer' + MSSQL_SA_PASSWORD: adminPassword + } + ports: { + sql: { + containerPort: 1433 + provides: sqlCatalogRoute.id + } + } + } + } +} + +resource sqlCatalogRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'sql-route-catalogdb' + properties: { + application: application + port: 1433 + } +} + +resource sqlOrderingContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'sql-server-orderingdb' + properties: { + application: application + container: { + image: 'mcr.microsoft.com/mssql/server:2019-latest' + env: { + ACCEPT_EULA: 'Y' + MSSQL_PID: 'Developer' + MSSQL_SA_PASSWORD: adminPassword + } + ports: { + sql: { + containerPort: 1433 + provides: sqlOrderingRoute.id + } + } + } + } +} + +resource sqlOrderingRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'sql-route-orderingdb' + properties: { + application: application + port: 1433 + } +} + +resource sqlWebhooksContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'sql-server-webhooksdb' + properties: { + application: application + container: { + image: 'mcr.microsoft.com/mssql/server:2019-latest' + env: { + ACCEPT_EULA: 'Y' + MSSQL_PID: 'Developer' + MSSQL_SA_PASSWORD: adminPassword + } + ports: { + sql: { + containerPort: 1433 + provides: sqlWebhooksRoute.id + } + } + } + } +} + +resource sqlWebhooksRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'sql-route-webhooksdb' + properties: { + application: application + port: 1433 + } +} + +resource redisBasketContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'redis-container-basket-data' + properties: { + application: application + container: { + image: 'redis:6.2' + env: {} + ports: { + redis: { + containerPort: 6379 + provides: redisBasketRoute.id + } + } + } + } +} + +resource redisBasketRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'redis-route-basket-data' + properties: { + application: application + port: 6379 + } +} + +resource redisKeystoreContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { + name: 'redis-container-keystore-data' + properties: { + application: application + container: { + image: 'redis:6.2' + env: {} + ports: { + redis: { + containerPort: 6379 + provides: redisKeystoreRoute.id + } + } + } + } +} + +resource redisKeystoreRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { + name: 'redis-route-keystore-data' + properties: { + application: application + port: 6379 + } +} + +// Links --------------------------------------------------------------- + +resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { + name: 'eshop-event-bus' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + queue: 'eshop-event-bus' + secrets: { + connectionString: rabbitmqRoute.properties.hostname + } + } +} + +resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'identitydb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + server: sqlIdentityRoute.properties.hostname + database: 'IdentityDb' + port: sqlIdentityRoute.properties.port + username: adminUsername + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sqlIdentityRoute.properties.hostname},${sqlIdentityRoute.properties.port};Initial Catalog=IdentityDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'catalogdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + server: sqlCatalogRoute.properties.hostname + database: 'CatalogDb' + port: sqlCatalogRoute.properties.port + username: adminUsername + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sqlCatalogRoute.properties.hostname},${sqlCatalogRoute.properties.port};Initial Catalog=CatalogDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'orderingdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + server: sqlOrderingRoute.properties.hostname + database: 'OrderingDb' + port: sqlOrderingRoute.properties.port + username: adminUsername + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sqlOrderingRoute.properties.hostname},${sqlOrderingRoute.properties.port};Initial Catalog=OrderingDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + } + } +} + +resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { + name: 'webhooksdb' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + server: sqlWebhooksRoute.properties.hostname + database: 'WebhooksDb' + port: sqlWebhooksRoute.properties.port + username: adminUsername + secrets: { + password: adminPassword + connectionString: 'Server=tcp:${sqlWebhooksRoute.properties.hostname},${sqlWebhooksRoute.properties.port};Initial Catalog=WebhooksDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + } + } +} + +resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'basket-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: redisBasketRoute.properties.hostname + port: redisBasketRoute.properties.port + secrets: { + connectionString: '${redisBasketRoute.properties.hostname}:${redisBasketRoute.properties.port},abortConnect=False' + } + } +} + +resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'keystore-data' + properties: { + application: application + environment: environment + resourceProvisioning: 'manual' + host: redisKeystoreRoute.properties.hostname + port: redisKeystoreRoute.properties.port + secrets: { + connectionString: '${redisKeystoreRoute.properties.hostname}:${redisKeystoreRoute.properties.port},abortConnect=False' + } + } +} + +// Outputs ------------------------------------ + +@description('The name of the SQL Identity Link') +output sqlIdentityDb string = sqlIdentityDb.name + +@description('The name of the SQL Catalog Link') +output sqlCatalogDb string = sqlCatalogDb.name + +@description('The name of the SQL Ordering Link') +output sqlOrderingDb string = sqlOrderingDb.name + +@description('The name of the SQL Webhooks Link') +output sqlWebhooksDb string = sqlWebhooksDb.name + +@description('The name of the Redis Keystore Link') +output redisKeystore string = redisKeystore.name + +@description('The name of the Redis Basket Link') +output redisBasket string = redisBasket.name + +@description('The name of the RabbitMQ Link') +output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/containers.bicep b/reference-apps/eshop/iac/infra/containers.bicep index 52c493f5..dffdcab2 100644 --- a/reference-apps/eshop/iac/infra/containers.bicep +++ b/reference-apps/eshop/iac/infra/containers.bicep @@ -6,233 +6,27 @@ param environment string @description('Radius application ID') param application string +@description('SQL administrator username') +param adminLogin string = 'sa' + @description('SQL administrator password') @secure() param adminPassword string -var adminUsername = 'sa' - -// Infrastructure ------------------------------------------------- - -resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rabbitmq-container-eshop-event-bus' - properties: { - application: application - container: { - image: 'rabbitmq:3.9' - env: {} - ports: { - rabbitmq: { - containerPort: 5672 - provides: rabbitmqRoute.id - } - } - } - } -} - -resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'rabbitmq-route-eshop-event-bus' - properties: { - application: application - port: 5672 - } -} - -resource sqlIdentityContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-identitydb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlIdentityRoute.id - } - } - } - } -} - -resource sqlIdentityRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-identitydb' - properties: { - application: application - port: 1433 - } -} - -resource sqlCatalogContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-catalogdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlCatalogRoute.id - } - } - } - } -} - -resource sqlCatalogRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-catalogdb' - properties: { - application: application - port: 1433 - } -} - -resource sqlOrderingContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-orderingdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlOrderingRoute.id - } - } - } - } -} - -resource sqlOrderingRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-orderingdb' - properties: { - application: application - port: 1433 - } -} - -resource sqlWebhooksContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-webhooksdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlWebhooksRoute.id - } - } - } - } -} - -resource sqlWebhooksRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-webhooksdb' - properties: { - application: application - port: 1433 - } -} - -resource redisBasketContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'redis-container-basket-data' - properties: { - application: application - container: { - image: 'redis:6.2' - env: {} - ports: { - redis: { - containerPort: 6379 - provides: redisBasketRoute.id - } - } - } - } -} - -resource redisBasketRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'redis-route-basket-data' - properties: { - application: application - port: 6379 - } -} - -resource redisKeystoreContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'redis-container-keystore-data' - properties: { - application: application - container: { - image: 'redis:6.2' - env: {} - ports: { - redis: { - containerPort: 6379 - provides: redisKeystoreRoute.id - } - } - } - } -} - -resource redisKeystoreRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'redis-route-keystore-data' - properties: { - application: application - port: 6379 - } -} - // Links --------------------------------------------------------------- -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: rabbitmqRoute.properties.hostname - } - } -} - resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' properties: { application: application environment: environment - resourceProvisioning: 'manual' - server: sqlIdentityRoute.properties.hostname - database: 'IdentityDb' - port: sqlIdentityRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlIdentityRoute.properties.hostname},${sqlIdentityRoute.properties.port};Initial Catalog=IdentityDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'containersmssql' + parameters: { + database: 'IdentityDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -242,14 +36,13 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' properties: { application: application environment: environment - resourceProvisioning: 'manual' - server: sqlCatalogRoute.properties.hostname - database: 'CatalogDb' - port: sqlCatalogRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlCatalogRoute.properties.hostname},${sqlCatalogRoute.properties.port};Initial Catalog=CatalogDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'containersmssql' + parameters: { + database: 'CatalogDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -259,14 +52,13 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - server: sqlOrderingRoute.properties.hostname - database: 'OrderingDb' - port: sqlOrderingRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlOrderingRoute.properties.hostname},${sqlOrderingRoute.properties.port};Initial Catalog=OrderingDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'containersmssql' + parameters: { + database: 'OrderingDb' + adminLogin: adminLogin + adminPassword: adminPassword + } } } } @@ -276,14 +68,24 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview properties: { application: application environment: environment - resourceProvisioning: 'manual' - server: sqlWebhooksRoute.properties.hostname - database: 'WebhooksDb' - port: sqlWebhooksRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlWebhooksRoute.properties.hostname},${sqlWebhooksRoute.properties.port};Initial Catalog=WebhooksDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' + recipe: { + name: 'containersmssql' + parameters: { + database: 'WebhooksDb' + adminLogin: adminLogin + adminPassword: adminPassword + } + } + } +} + +resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { + name: 'keystore-data' + properties: { + application: application + environment: environment + recipe: { + name: 'containersredis' } } } @@ -293,25 +95,19 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: redisBasketRoute.properties.hostname - port: redisBasketRoute.properties.port - secrets: { - connectionString: '${redisBasketRoute.properties.hostname}:${redisBasketRoute.properties.port},abortConnect=False' + recipe: { + name: 'containersredis' } } } -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { + name: 'rabbitmq' properties: { application: application environment: environment - resourceProvisioning: 'manual' - host: redisKeystoreRoute.properties.hostname - port: redisKeystoreRoute.properties.port - secrets: { - connectionString: '${redisKeystoreRoute.properties.hostname}:${redisKeystoreRoute.properties.port},abortConnect=False' + recipe: { + name: 'containersrabbitmq' } } } diff --git a/reference-apps/eshop/iac/infra/links.bicep b/reference-apps/eshop/iac/infra/links.bicep index 55cbdd13..3e923811 100644 --- a/reference-apps/eshop/iac/infra/links.bicep +++ b/reference-apps/eshop/iac/infra/links.bicep @@ -25,7 +25,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' e } resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: 'eshop-event-bus' + name: 'rabbitmq' } // Outputs -------------------------------------------------------------------------- diff --git a/reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep similarity index 100% rename from reference-apps/eshop/iac/infra/recipes/aws-mssql-recipe.bicep rename to reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep diff --git a/reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep similarity index 96% rename from reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep rename to reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep index 93c4fb14..c0bf7488 100644 --- a/reference-apps/eshop/iac/infra/recipes/aws-memorydb-recipe.bicep +++ b/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep @@ -44,6 +44,6 @@ output result object = { port: memoryDBCluster.properties.ClusterEndpoint.Port } secrets: { - url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port},ssl=true' + url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port}' } } diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep new file mode 100644 index 00000000..84400de1 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep @@ -0,0 +1,74 @@ +@description('Radius-provided object containing information about the resouce calling the Recipe') +param context object + +@description('The geo-location where the resource lives.') +param location string = resourceGroup().location + +@description('SQL administrator username') +param adminLogin string + +@description('SQL administrator password') +@secure() +param adminPassword string + +@description('Database name') +param database string + +@description('The type of MSSQL server to deploy. Valid values: (Basic, Standard, Premium)') +@allowed([ + 'Basic' + 'Standard' + 'Premium' +]) +param skuName string = 'Standard' + +@description('The size of the MSSQL server to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).') +@allowed([ + 'Basic' + 'Standard' + 'Premium' +]) +param skuTier string = 'Standard' + +var mssqlPort = 1433 + +resource mssql 'Microsoft.Sql/servers@2021-02-01-preview' = { + name: 'eshop-mssql-${uniqueString(context.resource.id, resourceGroup().id)}' + location: location + properties: { + administratorLogin: adminLogin + administratorLoginPassword: adminPassword + } + + resource firewallAllowEverything 'firewallRules' = { + name: 'firewall-allow-everything' + properties: { + startIpAddress: '0.0.0.0' + endIpAddress: '255.255.255.255' + } + } + + resource db 'databases' = { + name: database + location: location + sku: { + name: skuName + tier: skuTier + } + } +} + +output result object = { + values: { + server: mssql.properties.fullyQualifiedDomainName + port: mssqlPort + database: mssql::db.name + username: adminLogin + } + secrets: { + #disable-next-line outputs-should-not-contain-secrets + password: adminPassword + #disable-next-line outputs-should-not-contain-secrets + connectionString: 'Server=tcp:${mssql.properties.fullyQualifiedDomainName},${mssqlPort};Initial Catalog=${mssql::db.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep new file mode 100644 index 00000000..90732362 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep @@ -0,0 +1,49 @@ +@description('Radius-provided object containing information about the resouce calling the Recipe') +param context object + +@description('The geo-location where the resource lives.') +param location string = resourceGroup().location + +@description('The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).') +@minValue(0) +@maxValue(6) +param skuCapacity int = 0 + +@description('The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).') +@allowed([ + 'C' + 'P' +]) +param skuFamily string = 'C' + +@description('The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium)') +@allowed([ + 'Basic' + 'Standard' + 'Premium' +]) +param skuName string = 'Basic' + +resource azureCache 'Microsoft.Cache/redis@2022-06-01' = { + name: 'eshop-cache-${uniqueString(context.resource.id, resourceGroup().id)}' + location: location + properties: { + sku: { + capacity: skuCapacity + family: skuFamily + name: skuName + } + } +} + +output result object = { + values: { + host: azureCache.properties.hostName + port: azureCache.properties.sslPort + username: '' + } + secrets: { + #disable-next-line outputs-should-not-contain-secrets + password: azureCache.listKeys().primaryKey + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep new file mode 100644 index 00000000..ca327615 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep @@ -0,0 +1,129 @@ +@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') +param context object + +@description('Name of the SQL database. Defaults to the name of the Radius SQL resource.') +param database string = context.resource.name + +@description('SQL administrator username') +param adminLogin string + +@description('SQL administrator password') +@secure() +param adminPassword string + +@description('Tag to pull for the azure-sql-edge container image.') +param tag string = '1.0.7' + +@description('Memory request for the azure-sql-edge deployment.') +param memoryRequest string = '512Mi' + +@description('Memory limit for the azure-sql-edge deployment') +param memoryLimit string = '1024Mi' + +import kubernetes as kubernetes { + kubeConfig: '' + namespace: context.runtime.kubernetes.namespace +} + +var uniqueName = 'sql-${uniqueString(context.resource.id)}' +var port = 1433 + +resource sql 'apps/Deployment@v1' = { + metadata: { + name: uniqueName + } + spec: { + selector: { + matchLabels: { + app: 'sql' + resource: context.resource.name + } + } + template: { + metadata: { + labels: { + app: 'sql' + resource: context.resource.name + + // Label pods with the application name so `rad run` can find the logs. + 'radius.dev/application': context.application == null ? '' : context.application.name + } + } + spec: { + containers: [ + { + // This container is the running sql instance. + name: 'sql' + image: 'mcr.microsoft.com/azure-sql-edge:${tag}' + ports: [ + { + containerPort: port + } + ] + resources: { + requests: { + memory: memoryRequest + } + limits: { + memory: memoryLimit + } + } + env: [ + { + name: 'ACCEPT_EULA' + value: '1' + } + { + name: 'MSSQL_SA_PASSWORD' + value: adminPassword + } + ] + } + ] + } + } + } +} + +resource svc 'core/Service@v1' = { + metadata: { + name: uniqueName + labels: { + name: uniqueName + } + } + spec: { + type: 'ClusterIP' + selector: { + app: 'sql' + resource: context.resource.name + } + ports: [ + { + port: port + } + ] + } +} + +output result object = { + // This workaround is needed because the deployment engine omits Kubernetes resources from its output. + // This allows Kubernetes resources to be cleaned up when the resource is deleted. + // Once this gap is addressed, users won't need to do this. + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${sql.metadata.namespace}/providers/apps/Deployment/${sql.metadata.name}' + ] + values: { + server: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + port: port + database: database + username: adminLogin + } + secrets: { + #disable-next-line outputs-should-not-contain-secrets + password: adminPassword + #disable-next-line outputs-should-not-contain-secrets + connectionString: 'Server=tcp:${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local,${port};Initial Catalog=${database};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep similarity index 100% rename from reference-apps/eshop/iac/infra/recipes/container-rabbitmq-recipe.bicep rename to reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep diff --git a/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep new file mode 100644 index 00000000..974727b4 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep @@ -0,0 +1,93 @@ +@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') +param context object + +import kubernetes as kubernetes { + kubeConfig: '' + namespace: context.runtime.kubernetes.namespace +} + +resource redis 'apps/Deployment@v1' = { + metadata: { + name: 'redis-${uniqueString(context.resource.id)}' + } + spec: { + selector: { + matchLabels: { + app: 'redis' + resource: context.resource.name + } + } + template: { + metadata: { + labels: { + app: 'redis' + resource: context.resource.name + + // Label pods with the application name so `rad run` can find the logs. + 'radius.dev/application': context.application == null ? '' : context.application.name + } + } + spec: { + containers: [ + { + // This container is the running redis instance. + name: 'redis' + image: 'redis' + ports: [ + { + containerPort: 6379 + } + ] + } + { + // This container will connect to redis and stream logs to stdout for aid in development. + name: 'redis-monitor' + image: 'redis' + args: [ + 'redis-cli' + '-h' + 'localhost' + 'MONITOR' + ] + } + ] + } + } + } +} + +resource svc 'core/Service@v1' = { + metadata: { + name: 'redis-${uniqueString(context.resource.id)}' + } + spec: { + type: 'ClusterIP' + selector: { + app: 'redis' + resource: context.resource.name + } + ports: [ + { + port: 6379 + } + ] + } +} + +output result object = { + // This workaround is needed because the deployment engine omits Kubernetes resources from its output. + // This allows Kubernetes resources to be cleaned up when the resource is deleted. + // Once this gap is addressed, users won't need to do this. + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${redis.metadata.namespace}/providers/apps/Deployment/${redis.metadata.name}' + ] + values: { + host: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + port: 6379 + } + secrets: { + password: '' + url: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local:6379,abortConnect=False' + } +} diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index 303731fa..8a8281c9 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -11,19 +11,19 @@ param TAG string @description('Optional App Insights Key') param APPLICATION_INSIGHTS_KEY string -@description('Use Azure Service Bus for messaging.') -@allowed([ - 'True' - 'False' -]) -param AZURESERVICEBUSENABLED string - @description('What container orchestrator to use') @allowed([ 'K8S' ]) param ORCHESTRATOR_TYPE string +@description('Use Azure Service Bus for messaging') +@allowed([ + 'True' + 'False' +]) +param AZURESERVICEBUSENABLED string = 'False' + @description('The name of the Radius Gateway') param gatewayName string @@ -42,10 +42,6 @@ param redisBasketName string @description('The name of the RabbitMQ Link') param rabbitmqName string -@description('The connection string of the Azure Service Bus') -@secure() -param serviceBusConnectionString string - // Container ------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/basket-api @@ -65,8 +61,8 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { PORT: '80' GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - ConnectionString: '${redisBasket.connectionString()},ssl=true' - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + ConnectionString: '${redisBasket.connectionString()}' + EventBusConnection: rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index c4c71058..6f8d0396 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -26,9 +26,9 @@ param AZURESTORAGEENABLED string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string +param AZURESERVICEBUSENABLED string = 'False' -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Name of the Gateway') @@ -46,11 +46,8 @@ param rabbitmqName string @description('The name of the Catalog SQL Link') param sqlCatalogDbName string -@description('The connection string of the Azure Service Bus') -@secure() -param serviceBusConnectionString string - // VARIABLES ----------------------------------------------------------------------------------- + var PICBASEURL = '${gateway.properties.url}/webshoppingapigw/c/api/v1/catalog/items/[0]/pic' // CONTAINERS ------------------------------------------------------------------- @@ -74,7 +71,7 @@ resource catalog 'Applications.Core/containers@2022-03-15-privatepreview' = { ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlCatalogDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + EventBusConnection: rabbitmq.secrets('connectionString') } ports: { http: { diff --git a/reference-apps/eshop/iac/services/identity.bicep b/reference-apps/eshop/iac/services/identity.bicep index 256d550a..13044339 100644 --- a/reference-apps/eshop/iac/services/identity.bicep +++ b/reference-apps/eshop/iac/services/identity.bicep @@ -63,7 +63,7 @@ resource identity 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' OrchestratorType: 'K8S' IsClusterEnv: 'True' - DPConnectionString: '${redisKeystore.connectionString()},ssl=true' + DPConnectionString: '${redisKeystore.connectionString()}' ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY XamarinCallback: '' EnableDevspaces: ENABLEDEVSPACES diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index 01c3497c..77d7c97b 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -19,9 +19,9 @@ param APPLICATION_INSIGHTS_KEY string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string +param AZURESERVICEBUSENABLED string = 'False' -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Name of the Gateway') @@ -57,10 +57,6 @@ param rabbitmqName string @description('Name of the Ordering SQL Link') param sqlOrderingDbName string -@description('The connection string of the Azure Service Bus') -@secure() -param serviceBusConnectionString string - // CONTAINERS ------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/ordering-api @@ -85,7 +81,7 @@ resource ordering 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' PORT: '80' ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + EventBusConnection: rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -132,7 +128,7 @@ resource orderbgtasks 'Applications.Core/containers@2022-03-15-privatepreview' = OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + EventBusConnection: rabbitmq.secrets('connectionString') } ports: { http: { @@ -165,8 +161,8 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') - SignalrStoreConnectionString: '${redisKeystore.connectionString()},ssl=true' + EventBusConnection: rabbitmq.secrets('connectionString') + SignalrStoreConnectionString: '${redisKeystore.connectionString()}' identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/payment.bicep b/reference-apps/eshop/iac/services/payment.bicep index e4e55f89..04d310f9 100644 --- a/reference-apps/eshop/iac/services/payment.bicep +++ b/reference-apps/eshop/iac/services/payment.bicep @@ -19,9 +19,9 @@ param APPLICATION_INSIGHTS_KEY string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string +param AZURESERVICEBUSENABLED string = 'False' -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Name of the Payment HTTP route') @@ -30,10 +30,6 @@ param paymentHttpName string @description('The name of the RabbitMQ Link') param rabbitmqName string -@description('The connection string of the Azure Service Bus') -@secure() -param serviceBusConnectionString string - // CONTAINERS --------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/payment-api @@ -49,7 +45,7 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { 'Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ': 'Verbose' OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + EventBusConnection: rabbitmq.secrets('connectionString') } ports: { http: { diff --git a/reference-apps/eshop/iac/services/web.bicep b/reference-apps/eshop/iac/services/web.bicep index 35ea1b3b..b18cb6a8 100644 --- a/reference-apps/eshop/iac/services/web.bicep +++ b/reference-apps/eshop/iac/services/web.bicep @@ -14,7 +14,7 @@ param ORCHESTRATOR_TYPE string @description('Optional App Insights Key') param APPLICATION_INSIGHTS_KEY string -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Name of the Gateway') @@ -59,7 +59,7 @@ resource webspa 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' CallBackUrl: '${gateway.properties.url}/' - DPConnectionString: '${redisKeystore.connectionString()},ssl=true' + DPConnectionString: '${redisKeystore.connectionString()}' IdentityUrl: '${gateway.properties.url}/identity-api' IdentityUrlHC: '${identityHttp.properties.url}/hc' PurchaseUrl: '${gateway.properties.url}/webshoppingapigw' @@ -109,7 +109,7 @@ resource webmvc 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' PATH_BASE: '/webmvc' UseCustomizationData: 'False' - DPConnectionString: '${redisKeystore.connectionString()},ssl=true' + DPConnectionString: '${redisKeystore.connectionString()}' ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY UseLoadTest: 'False' OrchestratorType: ORCHESTRATOR_TYPE diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 581aedce..2fc62c28 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -16,9 +16,9 @@ param ORCHESTRATOR_TYPE string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string +param AZURESERVICEBUSENABLED string = 'False' -@description('Cotnainer image tag to use for eshop images. Defaults to linux-dotnet7') +@description('Container image tag to use for eshop images. Defaults to linux-dotnet7') param TAG string @description('Name of the Gateway') @@ -39,10 +39,6 @@ param sqlWebhooksDbName string @description('The name of the RabbitMQ Link') param rabbitmqName string -@description('The connection string of the Azure Service Bus') -@secure() -param serviceBusConnectionString string - // CONTAINERS ----------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/webhooks-api @@ -59,7 +55,7 @@ resource webhooks 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlWebhooksDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'True') ? serviceBusConnectionString : rabbitmq.secrets('connectionString') + EventBusConnection: rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/webshopping.bicep b/reference-apps/eshop/iac/services/webshopping.bicep index d3526dbb..c8e35957 100644 --- a/reference-apps/eshop/iac/services/webshopping.bicep +++ b/reference-apps/eshop/iac/services/webshopping.bicep @@ -11,7 +11,7 @@ param application string ]) param ORCHESTRATOR_TYPE string -@description('Cotnainer image tag to use for eshop images') +@description('Container image tag to use for eshop images') param TAG string @description('Name of the Gateway') From 191d9900260af1531c854ba9dc3d215d4bdc8e8a Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Wed, 12 Jul 2023 18:42:19 -0700 Subject: [PATCH 03/12] containers working with shared infra file --- reference-apps/eshop/iac/eshop.bicep | 66 +-- .../eshop/iac/infra/aws-infra.bicep | 322 -------------- reference-apps/eshop/iac/infra/aws.bicep | 133 ------ .../eshop/iac/infra/azure-infra.bicep | 395 ------------------ .../eshop/iac/infra/containers-infra.bicep | 340 --------------- .../eshop/iac/infra/containers.bicep | 136 ------ .../iac/infra/{azure.bicep => infra.bicep} | 25 +- reference-apps/eshop/iac/infra/links.bicep | 52 --- .../iac/infra/recipes/aws/awsrabbitmq.bicep | 102 +++++ .../infra/recipes/azure/azurerabbitmq.bicep | 102 +++++ .../eshop/iac/services/basket.bicep | 2 +- .../eshop/iac/services/identity.bicep | 2 +- .../eshop/iac/services/ordering.bicep | 2 +- reference-apps/eshop/iac/services/web.bicep | 4 +- 14 files changed, 242 insertions(+), 1441 deletions(-) delete mode 100644 reference-apps/eshop/iac/infra/aws-infra.bicep delete mode 100644 reference-apps/eshop/iac/infra/aws.bicep delete mode 100644 reference-apps/eshop/iac/infra/azure-infra.bicep delete mode 100644 reference-apps/eshop/iac/infra/containers-infra.bicep delete mode 100644 reference-apps/eshop/iac/infra/containers.bicep rename reference-apps/eshop/iac/infra/{azure.bicep => infra.bicep} (88%) delete mode 100644 reference-apps/eshop/iac/infra/links.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep create mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index 8bbf72e8..76a74072 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -67,9 +67,10 @@ resource eshop 'Applications.Core/applications@2022-03-15-privatepreview' = { // Infrastructure ------------------------------------------------------ -module containers 'infra/containers.bicep' = if (platform == 'containers') { - name: 'containers' +module infra 'infra/infra.bicep' = { + name: 'infra' params: { + platform: platform application: eshop.id environment: environment adminLogin: adminLogin @@ -77,39 +78,6 @@ module containers 'infra/containers.bicep' = if (platform == 'containers') { } } -module azure 'infra/azure.bicep' = if (platform == 'azure') { - name: 'azure' - // Temporarily disable linter rule until deployment engine returns Azure resource group location instead of UCP resource group location - #disable-next-line explicit-values-for-loc-params - params: { - application: eshop.id - environment: environment - adminLogin: adminLogin - adminPassword: adminPassword - } -} - -module aws 'infra/aws.bicep' = if (platform == 'aws') { - name: 'aws' - params: { - application: eshop.id - environment: environment - adminLogin: adminLogin - adminPassword: adminPassword - } -} - -// Links ----------------------------------------------------------- - -module links 'infra/links.bicep' = { - name: 'links' - dependsOn: [ - containers - azure - aws - ] -} - // Networking ---------------------------------------------------------- module networking 'services/networking.bicep' = { @@ -132,8 +100,8 @@ module basket 'services/basket.bicep' = { identityHttpName: networking.outputs.identityHttp basketHttpName: networking.outputs.basketHttp basketGrpcName: networking.outputs.basketGrpc - rabbitmqName: links.outputs.rabbitmq - redisBasketName: links.outputs.redisBasket + rabbitmqName: infra.outputs.rabbitmq + redisBasketName: infra.outputs.redisBasket TAG: TAG } } @@ -149,8 +117,8 @@ module catalog 'services/catalog.bicep' = { catalogHttpName: networking.outputs.catalogHttp gatewayName: networking.outputs.gateway ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE - rabbitmqName: links.outputs.rabbitmq - sqlCatalogDbName: links.outputs.sqlCatalogDb + rabbitmqName: infra.outputs.rabbitmq + sqlCatalogDbName: infra.outputs.sqlCatalogDb TAG: TAG } } @@ -165,8 +133,8 @@ module identity 'services/identity.bicep' = { gatewayName: networking.outputs.gateway identityHttpName: networking.outputs.identityHttp orderingHttpName: networking.outputs.orderingHttp - redisKeystoreName: links.outputs.redisKeystore - sqlIdentityDbName: links.outputs.sqlIdentityDb + redisKeystoreName: infra.outputs.redisKeystore + sqlIdentityDbName: infra.outputs.sqlIdentityDb TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp @@ -190,9 +158,9 @@ module ordering 'services/ordering.bicep' = { orderingGrpcName: networking.outputs.orderingGrpc orderingHttpName: networking.outputs.orderingHttp orderingsignalrhubHttpName: networking.outputs.orderingsignalrhubHttp - rabbitmqName: links.outputs.rabbitmq - redisKeystoreName: links.outputs.redisKeystore - sqlOrderingDbName: links.outputs.sqlOrderingDb + rabbitmqName: infra.outputs.rabbitmq + redisKeystoreName: infra.outputs.redisKeystore + sqlOrderingDbName: infra.outputs.sqlOrderingDb TAG: TAG } } @@ -205,7 +173,7 @@ module payment 'services/payment.bicep' = { AZURESERVICEBUSENABLED: AZURESERVICEBUSENABLED ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE paymentHttpName: networking.outputs.paymentHttp - rabbitmqName: links.outputs.rabbitmq + rabbitmqName: infra.outputs.rabbitmq TAG: TAG } } @@ -227,7 +195,7 @@ module web 'services/web.bicep' = { identityHttpName: networking.outputs.identityHttp ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE orderingsignalrhubHttpName: networking.outputs.orderingsignalrhubHttp - redisKeystoreName: links.outputs.redisKeystore + redisKeystoreName: infra.outputs.redisKeystore TAG: TAG webmvcHttpName: networking.outputs.webmvcHttp webshoppingaggHttpName: networking.outputs.webshoppingaggHttp @@ -244,8 +212,8 @@ module webhooks 'services/webhooks.bicep' = { gatewayName: networking.outputs.gateway identityHttpName: networking.outputs.identityHttp ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE - rabbitmqName: links.outputs.rabbitmq - sqlWebhooksDbName: links.outputs.sqlWebhooksDb + rabbitmqName: infra.outputs.rabbitmq + sqlWebhooksDbName: infra.outputs.sqlWebhooksDb TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp @@ -266,7 +234,7 @@ module webshopping 'services/webshopping.bicep' = { orderingGrpcName: networking.outputs.orderingGrpc orderingHttpName: networking.outputs.basketHttp paymentHttpName: networking.outputs.paymentHttp - rabbitmqName: links.outputs.rabbitmq + rabbitmqName: infra.outputs.rabbitmq TAG: TAG webshoppingaggHttpName: networking.outputs.webshoppingaggHttp webshoppingapigwHttp2Name: networking.outputs.webshoppingapigwHttp2 diff --git a/reference-apps/eshop/iac/infra/aws-infra.bicep b/reference-apps/eshop/iac/infra/aws-infra.bicep deleted file mode 100644 index f8b93814..00000000 --- a/reference-apps/eshop/iac/infra/aws-infra.bicep +++ /dev/null @@ -1,322 +0,0 @@ -import radius as radius -import aws as aws - -@description('Radius environment ID') -param environment string - -@description('Radius application ID') -param application string - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -@description('Name of the EKS cluster where the application will be run. Used to setup subnet groups') -param eksClusterName string - -// Infrastructure ------------------------------------------------------------ - -resource eksCluster 'AWS.EKS/Cluster@default' existing = { - alias: eksClusterName - properties: { - Name: eksClusterName - } -} - -var sqlSubnetGroupName = 'eshopsqlsg${uniqueString(application)}' -resource sqlSubnetGroup 'AWS.RDS/DBSubnetGroup@default' = { - alias: sqlSubnetGroupName - properties: { - DBSubnetGroupName: sqlSubnetGroupName - DBSubnetGroupDescription: sqlSubnetGroupName - SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds - } -} - -var identityDbIdentifier = 'eshopidentitysql${uniqueString(application)}' -resource identityDb 'AWS.RDS/DBInstance@default' = { - alias: identityDbIdentifier - properties: { - DBInstanceIdentifier: identityDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var catalogDbIdentifier = 'eshopcatalogsql${uniqueString(application)}' -resource catalogDb 'AWS.RDS/DBInstance@default' = { - alias: catalogDbIdentifier - properties: { - DBInstanceIdentifier: catalogDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var orderingDbIdentifier = 'eshoporderingsql${uniqueString(application)}' -resource orderingDb 'AWS.RDS/DBInstance@default' = { - alias: orderingDbIdentifier - properties: { - DBInstanceIdentifier: orderingDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var webhooksDbIdentifier = 'eshopwebhookssql${uniqueString(application)}' -resource webhooksDb 'AWS.RDS/DBInstance@default' = { - alias: webhooksDbIdentifier - properties: { - DBInstanceIdentifier: webhooksDbIdentifier - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - Port: '1433' - DBSubnetGroupName: sqlSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -var redisSubnetGroupName = 'eshopredissg${uniqueString(application)}' -resource redisSubnetGroup 'AWS.MemoryDB/SubnetGroup@default' = { - alias: redisSubnetGroupName - properties: { - SubnetGroupName: redisSubnetGroupName - SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds - } -} - -var keystoreCacheName = 'eshopkeystore${uniqueString(application)}' -resource keystoreCache 'AWS.MemoryDB/Cluster@default' = { - alias: keystoreCacheName - properties: { - ClusterName: keystoreCacheName - NodeType: 'db.t4g.small' - ACLName: 'open-access' - SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] - SubnetGroupName: redisSubnetGroup.properties.SubnetGroupName - NumReplicasPerShard: 0 - } -} - -var basketCacheName = 'eshopbasket${uniqueString(application)}' -resource basketCache 'AWS.MemoryDB/Cluster@default' = { - alias: basketCacheName - properties: { - ClusterName: basketCacheName - NodeType: 'db.t4g.small' - ACLName: 'open-access' - SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] - SubnetGroupName: redisSubnetGroup.name - NumReplicasPerShard: 0 - } -} - -// TEMP: Using containerized rabbitMQ instead of AWS SNS until AWS nonidempotency is resolved -resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rabbitmq-container-eshop-event-bus' - properties: { - application: application - container: { - image: 'rabbitmq:3.9' - env: {} - ports: { - rabbitmq: { - containerPort: 5672 - provides: rabbitmqRoute.id - } - } - } - } -} - -resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'rabbitmq-route-eshop-event-bus' - properties: { - application: application - port: 5672 - } -} - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'identitydb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: 'IdentityDb' - server: identityDb.properties.Endpoint.Address - port: int(identityDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${identityDb.properties.Endpoint.Address},${identityDb.properties.Endpoint.Port};Initial Catalog=IdentityDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'catalogdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: 'CatalogDb' - server: catalogDb.properties.Endpoint.Address - port: int(catalogDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${catalogDb.properties.Endpoint.Address},${catalogDb.properties.Endpoint.Port};Initial Catalog=CatalogDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'orderingdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: 'OrderingDb' - server: orderingDb.properties.Endpoint.Address - port: int(orderingDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${orderingDb.properties.Endpoint.Address},${orderingDb.properties.Endpoint.Port};Initial Catalog=OrderingDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'webhooksdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: 'WebhooksDb' - server: webhooksDb.properties.Endpoint.Address - port: int(webhooksDb.properties.Endpoint.Port) - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${webhooksDb.properties.Endpoint.Address},${webhooksDb.properties.Endpoint.Port};Initial Catalog=WebhooksDb;User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - } -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: keystoreCache.properties.ClusterEndpoint.Address - port: keystoreCache.properties.ClusterEndpoint.Port - secrets: { - connectionString: '${keystoreCache.properties.ClusterEndpoint.Address}:${keystoreCache.properties.ClusterEndpoint.Port}' - } - } -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'basket-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: basketCache.properties.ClusterEndpoint.Address - port: basketCache.properties.ClusterEndpoint.Port - secrets: { - connectionString: '${basketCache.properties.ClusterEndpoint.Address}:${basketCache.properties.ClusterEndpoint.Port}' - } - } -} - -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: rabbitmqRoute.properties.hostname - } - } -} - -// Outputs ------------------------------------ - -@description('The name of the SQL Identity Link') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Catalog Link') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Ordering Link') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Webhooks Link') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Keystore Link') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Basket Link') -output redisBasket string = redisBasket.name - -@description('The name of the RabbitMQ Link') -output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/aws.bicep b/reference-apps/eshop/iac/infra/aws.bicep deleted file mode 100644 index 70b6fb5b..00000000 --- a/reference-apps/eshop/iac/infra/aws.bicep +++ /dev/null @@ -1,133 +0,0 @@ -import radius as radius -import aws as aws - -@description('Radius environment ID') -param environment string - -@description('Radius application ID') -param application string - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'identitydb' - properties: { - application: application - environment: environment - recipe: { - name: 'awsmssql' - parameters: { - database: 'IdentityDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'catalogdb' - properties: { - application: application - environment: environment - recipe: { - name: 'awsmssql' - parameters: { - database: 'CatalogDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'orderingdb' - properties: { - application: application - environment: environment - recipe: { - name: 'awsmssql' - parameters: { - database: 'OrderingDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'webhooksdb' - properties: { - application: application - environment: environment - recipe: { - name: 'awsmssql' - parameters: { - database: 'WebhooksDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' - properties: { - application: application - environment: environment - recipe: { - name: 'awsredis' - } - } -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'basket-data' - properties: { - application: application - environment: environment - recipe: { - name: 'awsredis' - } - } -} - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { - name: 'rabbitmq' - properties: { - application: application - environment: environment - recipe: { - name: 'containersrabbitmq' - } - } -} - -@description('The name of the SQL Identity Link') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Catalog Link') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Ordering Link') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Webhooks Link') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Keystore Link') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Basket Link') -output redisBasket string = redisBasket.name - -@description('The name of the RabbitMQ Link') -output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/azure-infra.bicep b/reference-apps/eshop/iac/infra/azure-infra.bicep deleted file mode 100644 index 5472e9a3..00000000 --- a/reference-apps/eshop/iac/infra/azure-infra.bicep +++ /dev/null @@ -1,395 +0,0 @@ -import radius as rad -import az as az - -@description('Azure region to deploy resources into') -param location string = resourceGroup().location - -@description('Radius environment ID') -param environment string - -@description('Radius application ID') -param application string - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -var sqlPort = 1433 - -// Infrastructure ------------------------------------------------------------ -// TODO: Move the infrastructure into Recipes - -resource servicebus 'Microsoft.ServiceBus/namespaces@2021-06-01-preview' = { - name: 'eshop${uniqueString(resourceGroup().id)}' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - - resource topic 'topics' = { - name: 'eshop_event_bus' - properties: { - defaultMessageTimeToLive: 'P14D' - maxSizeInMegabytes: 1024 - requiresDuplicateDetection: false - enableBatchedOperations: true - supportOrdering: false - enablePartitioning: true - enableExpress: false - } - - resource rootRule 'authorizationRules' = { - name: 'Root' - properties: { - rights: [ - 'Manage' - 'Send' - 'Listen' - ] - } - } - - resource basket 'subscriptions' = { - name: 'Basket' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource catalog 'subscriptions' = { - name: 'Catalog' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource ordering 'subscriptions' = { - name: 'Ordering' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource graceperiod 'subscriptions' = { - name: 'GracePeriod' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource payment 'subscriptions' = { - name: 'Payment' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource backgroundTasks 'subscriptions' = { - name: 'backgroundtasks' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource OrderingSignalrHub 'subscriptions' = { - name: 'Ordering.signalrhub' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - - resource webhooks 'subscriptions' = { - name: 'Webhooks' - properties: { - requiresSession: false - defaultMessageTimeToLive: 'P14D' - deadLetteringOnMessageExpiration: true - deadLetteringOnFilterEvaluationExceptions: true - maxDeliveryCount: 10 - enableBatchedOperations: true - } - } - } -} - -resource sql 'Microsoft.Sql/servers@2021-02-01-preview' = { - name: 'eshopsql${uniqueString(resourceGroup().id)}' - location: location - properties: { - administratorLogin: adminLogin - administratorLoginPassword: adminPassword - } - - resource allowEverything 'firewallRules' = { - name: 'allow-everrything' - properties: { - startIpAddress: '0.0.0.0' - endIpAddress: '255.255.255.255' - } - } - - resource identityDb 'databases' = { - name: 'IdentityDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource catalogDb 'databases' = { - name: 'CatalogDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource orderingDb 'databases' = { - name: 'OrderingDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } - - resource webhooksDb 'databases' = { - name: 'WebhooksDb' - location: location - sku: { - name: 'Standard' - tier: 'Standard' - } - } -} - -resource keystoreCache 'Microsoft.Cache/redis@2020-12-01' = { - name: 'eshopkeystore${uniqueString(resourceGroup().id)}' - location: location - properties: { - enableNonSslPort: false - minimumTlsVersion: '1.2' - sku: { - family: 'C' - capacity: 1 - name: 'Basic' - } - } -} - -resource basketCache 'Microsoft.Cache/redis@2020-12-01' = { - name: 'eshopbasket${uniqueString(resourceGroup().id)}' - location: location - properties: { - enableNonSslPort: false - minimumTlsVersion: '1.2' - sku: { - family: 'C' - capacity: 1 - name: 'Basic' - } - } -} - -// Links ---------------------------------------------------------------------------- -// TODO: Move the Link definitions into the application and use Recipes instead - -// Need to deploy a blank rabbitmq instance to let Bicep successfully deploy -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: 'test' - } - } -} - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'identitydb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: sql::identityDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::identityDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::identityDb.id - } - ] - } -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'catalogdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: sql::catalogDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::catalogDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::catalogDb.id - } - ] - } -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'orderingdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: sql::orderingDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::orderingDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::orderingDb.id - } - ] - } -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'webhooksdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - database: sql::webhooksDb.name - server: sql.properties.fullyQualifiedDomainName - port: sqlPort - username: adminLogin - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sql.properties.fullyQualifiedDomainName},${sqlPort};Initial Catalog=${sql::webhooksDb.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } - resources: [ - { - id: sql::webhooksDb.id - } - ] - } -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'basket-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: basketCache.properties.hostName - port: basketCache.properties.sslPort - secrets: { - password: basketCache.listKeys().primaryKey - connectionString: '${basketCache.properties.hostName}:${basketCache.properties.sslPort},password=${basketCache.listKeys().primaryKey},abortConnect=False' - } - } -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: keystoreCache.properties.hostName - port: keystoreCache.properties.sslPort - secrets: { - password: keystoreCache.listKeys().primaryKey - connectionString: '${keystoreCache.properties.hostName}:${keystoreCache.properties.sslPort},password=${keystoreCache.listKeys().primaryKey},abortConnect=False' - } - } -} - -// Outputs ------------------------------------ - -@description('The ID of the auth rule') -#disable-next-line outputs-should-not-contain-secrets -output serviceBusAuthConnectionString string = servicebus::topic::rootRule.listKeys().primaryConnectionString - -@description('The name of the RabbitMQ Queue') -output rabbitMqQueue string = rabbitmq.name - -@description('The name of the SQL Identity Link') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Catalog Link') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Ordering Link') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Webhooks Link') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Keystore Link') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Basket Link') -output redisBasket string = redisBasket.name diff --git a/reference-apps/eshop/iac/infra/containers-infra.bicep b/reference-apps/eshop/iac/infra/containers-infra.bicep deleted file mode 100644 index 52c493f5..00000000 --- a/reference-apps/eshop/iac/infra/containers-infra.bicep +++ /dev/null @@ -1,340 +0,0 @@ -import radius as rad - -@description('Radius environment ID') -param environment string - -@description('Radius application ID') -param application string - -@description('SQL administrator password') -@secure() -param adminPassword string - -var adminUsername = 'sa' - -// Infrastructure ------------------------------------------------- - -resource rabbitmqContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'rabbitmq-container-eshop-event-bus' - properties: { - application: application - container: { - image: 'rabbitmq:3.9' - env: {} - ports: { - rabbitmq: { - containerPort: 5672 - provides: rabbitmqRoute.id - } - } - } - } -} - -resource rabbitmqRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'rabbitmq-route-eshop-event-bus' - properties: { - application: application - port: 5672 - } -} - -resource sqlIdentityContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-identitydb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlIdentityRoute.id - } - } - } - } -} - -resource sqlIdentityRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-identitydb' - properties: { - application: application - port: 1433 - } -} - -resource sqlCatalogContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-catalogdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlCatalogRoute.id - } - } - } - } -} - -resource sqlCatalogRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-catalogdb' - properties: { - application: application - port: 1433 - } -} - -resource sqlOrderingContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-orderingdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlOrderingRoute.id - } - } - } - } -} - -resource sqlOrderingRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-orderingdb' - properties: { - application: application - port: 1433 - } -} - -resource sqlWebhooksContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'sql-server-webhooksdb' - properties: { - application: application - container: { - image: 'mcr.microsoft.com/mssql/server:2019-latest' - env: { - ACCEPT_EULA: 'Y' - MSSQL_PID: 'Developer' - MSSQL_SA_PASSWORD: adminPassword - } - ports: { - sql: { - containerPort: 1433 - provides: sqlWebhooksRoute.id - } - } - } - } -} - -resource sqlWebhooksRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'sql-route-webhooksdb' - properties: { - application: application - port: 1433 - } -} - -resource redisBasketContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'redis-container-basket-data' - properties: { - application: application - container: { - image: 'redis:6.2' - env: {} - ports: { - redis: { - containerPort: 6379 - provides: redisBasketRoute.id - } - } - } - } -} - -resource redisBasketRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'redis-route-basket-data' - properties: { - application: application - port: 6379 - } -} - -resource redisKeystoreContainer 'Applications.Core/containers@2022-03-15-privatepreview' = { - name: 'redis-container-keystore-data' - properties: { - application: application - container: { - image: 'redis:6.2' - env: {} - ports: { - redis: { - containerPort: 6379 - provides: redisKeystoreRoute.id - } - } - } - } -} - -resource redisKeystoreRoute 'Applications.Core/httproutes@2022-03-15-privatepreview' = { - name: 'redis-route-keystore-data' - properties: { - application: application - port: 6379 - } -} - -// Links --------------------------------------------------------------- - -resource rabbitmq 'Applications.Link/rabbitmqMessageQueues@2022-03-15-privatepreview' = { - name: 'eshop-event-bus' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - queue: 'eshop-event-bus' - secrets: { - connectionString: rabbitmqRoute.properties.hostname - } - } -} - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'identitydb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - server: sqlIdentityRoute.properties.hostname - database: 'IdentityDb' - port: sqlIdentityRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlIdentityRoute.properties.hostname},${sqlIdentityRoute.properties.port};Initial Catalog=IdentityDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'catalogdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - server: sqlCatalogRoute.properties.hostname - database: 'CatalogDb' - port: sqlCatalogRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlCatalogRoute.properties.hostname},${sqlCatalogRoute.properties.port};Initial Catalog=CatalogDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'orderingdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - server: sqlOrderingRoute.properties.hostname - database: 'OrderingDb' - port: sqlOrderingRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlOrderingRoute.properties.hostname},${sqlOrderingRoute.properties.port};Initial Catalog=OrderingDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' - } - } -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'webhooksdb' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - server: sqlWebhooksRoute.properties.hostname - database: 'WebhooksDb' - port: sqlWebhooksRoute.properties.port - username: adminUsername - secrets: { - password: adminPassword - connectionString: 'Server=tcp:${sqlWebhooksRoute.properties.hostname},${sqlWebhooksRoute.properties.port};Initial Catalog=WebhooksDb;User Id=${adminUsername};Password=${adminPassword};Encrypt=false' - } - } -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'basket-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: redisBasketRoute.properties.hostname - port: redisBasketRoute.properties.port - secrets: { - connectionString: '${redisBasketRoute.properties.hostname}:${redisBasketRoute.properties.port},abortConnect=False' - } - } -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' - properties: { - application: application - environment: environment - resourceProvisioning: 'manual' - host: redisKeystoreRoute.properties.hostname - port: redisKeystoreRoute.properties.port - secrets: { - connectionString: '${redisKeystoreRoute.properties.hostname}:${redisKeystoreRoute.properties.port},abortConnect=False' - } - } -} - -// Outputs ------------------------------------ - -@description('The name of the SQL Identity Link') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Catalog Link') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Ordering Link') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Webhooks Link') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Keystore Link') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Basket Link') -output redisBasket string = redisBasket.name - -@description('The name of the RabbitMQ Link') -output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/containers.bicep b/reference-apps/eshop/iac/infra/containers.bicep deleted file mode 100644 index dffdcab2..00000000 --- a/reference-apps/eshop/iac/infra/containers.bicep +++ /dev/null @@ -1,136 +0,0 @@ -import radius as rad - -@description('Radius environment ID') -param environment string - -@description('Radius application ID') -param application string - -@description('SQL administrator username') -param adminLogin string = 'sa' - -@description('SQL administrator password') -@secure() -param adminPassword string - -// Links --------------------------------------------------------------- - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'identitydb' - properties: { - application: application - environment: environment - recipe: { - name: 'containersmssql' - parameters: { - database: 'IdentityDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'catalogdb' - properties: { - application: application - environment: environment - recipe: { - name: 'containersmssql' - parameters: { - database: 'CatalogDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'orderingdb' - properties: { - application: application - environment: environment - recipe: { - name: 'containersmssql' - parameters: { - database: 'OrderingDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { - name: 'webhooksdb' - properties: { - application: application - environment: environment - recipe: { - name: 'containersmssql' - parameters: { - database: 'WebhooksDb' - adminLogin: adminLogin - adminPassword: adminPassword - } - } - } -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'keystore-data' - properties: { - application: application - environment: environment - recipe: { - name: 'containersredis' - } - } -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { - name: 'basket-data' - properties: { - application: application - environment: environment - recipe: { - name: 'containersredis' - } - } -} - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { - name: 'rabbitmq' - properties: { - application: application - environment: environment - recipe: { - name: 'containersrabbitmq' - } - } -} - -// Outputs ------------------------------------ - -@description('The name of the SQL Identity Link') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Catalog Link') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Ordering Link') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Webhooks Link') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Keystore Link') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Basket Link') -output redisBasket string = redisBasket.name - -@description('The name of the RabbitMQ Link') -output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/azure.bicep b/reference-apps/eshop/iac/infra/infra.bicep similarity index 88% rename from reference-apps/eshop/iac/infra/azure.bicep rename to reference-apps/eshop/iac/infra/infra.bicep index f8778f4a..9ed82704 100644 --- a/reference-apps/eshop/iac/infra/azure.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -1,5 +1,12 @@ import radius as rad -import az as az + +@description('What type of infrastructure to use. Options are "containers", "azure", or "aws"') +@allowed([ + 'containers' + 'azure' + 'aws' +]) +param platform string @description('Radius environment ID') param environment string @@ -14,7 +21,7 @@ param adminLogin string @secure() param adminPassword string -// Links ---------------------------------------------------------------------------- +// Links --------------------------------------------------------------- resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' @@ -22,7 +29,7 @@ resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: 'azuremssql' + name: '${platform}mssql' parameters: { database: 'IdentityDb' adminLogin: adminLogin @@ -38,7 +45,7 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: 'azuremssql' + name: '${platform}mssql' parameters: { database: 'CatalogDb' adminLogin: adminLogin @@ -54,7 +61,7 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: 'azuremssql' + name: '${platform}mssql' parameters: { database: 'OrderingDb' adminLogin: adminLogin @@ -70,7 +77,7 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: 'azuremssql' + name: '${platform}mssql' parameters: { database: 'WebhooksDb' adminLogin: adminLogin @@ -86,7 +93,7 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: 'azureredis' + name: '${platform}redis' } } } @@ -97,7 +104,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = application: application environment: environment recipe: { - name: 'azureredis' + name: '${platform}redis' } } } @@ -108,7 +115,7 @@ resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { application: application environment: environment recipe: { - name: 'containersrabbitmq' + name: '${platform}rabbitmq' } } } diff --git a/reference-apps/eshop/iac/infra/links.bicep b/reference-apps/eshop/iac/infra/links.bicep deleted file mode 100644 index 3e923811..00000000 --- a/reference-apps/eshop/iac/infra/links.bicep +++ /dev/null @@ -1,52 +0,0 @@ -import radius as rad - -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { - name: 'identitydb' -} - -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { - name: 'catalogdb' -} - -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { - name: 'orderingdb' -} - -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { - name: 'webhooksdb' -} - -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { - name: 'keystore-data' -} - -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { - name: 'basket-data' -} - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: 'rabbitmq' -} - -// Outputs -------------------------------------------------------------------------- - -@description('The name of the SQL Database for Identity.') -output sqlIdentityDb string = sqlIdentityDb.name - -@description('The name of the SQL Database for Catalog.') -output sqlCatalogDb string = sqlCatalogDb.name - -@description('The name of the SQL Database for Ordering.') -output sqlOrderingDb string = sqlOrderingDb.name - -@description('The name of the SQL Database for Webhooks.') -output sqlWebhooksDb string = sqlWebhooksDb.name - -@description('The name of the Redis Cache for Keystore.') -output redisKeystore string = redisKeystore.name - -@description('The name of the Redis Cache for Basket.') -output redisBasket string = redisBasket.name - -@description('The name of the RabbitMQ Message Queue.') -output rabbitmq string = rabbitmq.name diff --git a/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep new file mode 100644 index 00000000..eb94de83 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep @@ -0,0 +1,102 @@ +@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') +param context object + +@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') +param queue string = context.resource.name + +@description('Tag to pull for the rabbitmq container image.') +param tag string = '3' + +@description('Memory request for the rabbitmq deployment.') +param memoryRequest string = '256Mi' + +@description('Memory limit for the rabbitmq deployment') +param memoryLimit string = '1024Mi' + +import kubernetes as kubernetes { + kubeConfig: '' + namespace: context.runtime.kubernetes.namespace +} + +var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' +var port = 5672 + +resource rabbitmq 'apps/Deployment@v1' = { + metadata: { + name: uniqueName + } + spec: { + selector: { + matchLabels: { + app: 'rabbitmq' + resource: context.resource.name + } + } + template: { + metadata: { + labels: { + app: 'rabbitmq' + resource: context.resource.name + // Label pods with the application name so `rad run` can find the logs. + 'radius.dev/application': context.application == null ? '' : context.application.name + } + } + spec: { + containers: [ + { + name: 'rabbitmq' + image: 'rabbitmq:${tag}' + ports: [ + { + containerPort: port + } + ] + resources: { + requests: { + memory: memoryRequest + } + limits: { + memory: memoryLimit + } + } + env: [] + } + ] + } + } + } +} + +resource svc 'core/Service@v1' = { + metadata: { + name: uniqueName + labels: { + name: uniqueName + } + } + spec: { + type: 'ClusterIP' + selector: { + app: 'rabbitmq' + resource: context.resource.name + } + ports: [ + { + port: port + } + ] + } +} + +output result object = { + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' + ] + values: { + queue: queue + } + secrets: { + connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + } +} diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep new file mode 100644 index 00000000..eb94de83 --- /dev/null +++ b/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep @@ -0,0 +1,102 @@ +@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') +param context object + +@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') +param queue string = context.resource.name + +@description('Tag to pull for the rabbitmq container image.') +param tag string = '3' + +@description('Memory request for the rabbitmq deployment.') +param memoryRequest string = '256Mi' + +@description('Memory limit for the rabbitmq deployment') +param memoryLimit string = '1024Mi' + +import kubernetes as kubernetes { + kubeConfig: '' + namespace: context.runtime.kubernetes.namespace +} + +var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' +var port = 5672 + +resource rabbitmq 'apps/Deployment@v1' = { + metadata: { + name: uniqueName + } + spec: { + selector: { + matchLabels: { + app: 'rabbitmq' + resource: context.resource.name + } + } + template: { + metadata: { + labels: { + app: 'rabbitmq' + resource: context.resource.name + // Label pods with the application name so `rad run` can find the logs. + 'radius.dev/application': context.application == null ? '' : context.application.name + } + } + spec: { + containers: [ + { + name: 'rabbitmq' + image: 'rabbitmq:${tag}' + ports: [ + { + containerPort: port + } + ] + resources: { + requests: { + memory: memoryRequest + } + limits: { + memory: memoryLimit + } + } + env: [] + } + ] + } + } + } +} + +resource svc 'core/Service@v1' = { + metadata: { + name: uniqueName + labels: { + name: uniqueName + } + } + spec: { + type: 'ClusterIP' + selector: { + app: 'rabbitmq' + resource: context.resource.name + } + ports: [ + { + port: port + } + ] + } +} + +output result object = { + resources: [ + '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' + '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' + ] + values: { + queue: queue + } + secrets: { + connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' + } +} diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index 8a8281c9..4eea90a2 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -61,7 +61,7 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { PORT: '80' GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - ConnectionString: '${redisBasket.connectionString()}' + ConnectionString: redisBasket.connectionString() EventBusConnection: rabbitmq.secrets('connectionString') identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' diff --git a/reference-apps/eshop/iac/services/identity.bicep b/reference-apps/eshop/iac/services/identity.bicep index 13044339..484af5ab 100644 --- a/reference-apps/eshop/iac/services/identity.bicep +++ b/reference-apps/eshop/iac/services/identity.bicep @@ -63,7 +63,7 @@ resource identity 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' OrchestratorType: 'K8S' IsClusterEnv: 'True' - DPConnectionString: '${redisKeystore.connectionString()}' + DPConnectionString: redisKeystore.connectionString() ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY XamarinCallback: '' EnableDevspaces: ENABLEDEVSPACES diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index 77d7c97b..b1ad18e3 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -162,7 +162,7 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED EventBusConnection: rabbitmq.secrets('connectionString') - SignalrStoreConnectionString: '${redisKeystore.connectionString()}' + SignalrStoreConnectionString: redisKeystore.connectionString() identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/web.bicep b/reference-apps/eshop/iac/services/web.bicep index b18cb6a8..5de919f6 100644 --- a/reference-apps/eshop/iac/services/web.bicep +++ b/reference-apps/eshop/iac/services/web.bicep @@ -59,7 +59,7 @@ resource webspa 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' CallBackUrl: '${gateway.properties.url}/' - DPConnectionString: '${redisKeystore.connectionString()}' + DPConnectionString: redisKeystore.connectionString() IdentityUrl: '${gateway.properties.url}/identity-api' IdentityUrlHC: '${identityHttp.properties.url}/hc' PurchaseUrl: '${gateway.properties.url}/webshoppingapigw' @@ -109,7 +109,7 @@ resource webmvc 'Applications.Core/containers@2022-03-15-privatepreview' = { ASPNETCORE_URLS: 'http://0.0.0.0:80' PATH_BASE: '/webmvc' UseCustomizationData: 'False' - DPConnectionString: '${redisKeystore.connectionString()}' + DPConnectionString: redisKeystore.connectionString() ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY UseLoadTest: 'False' OrchestratorType: ORCHESTRATOR_TYPE From d0c35988335b29b8d554bdaa0edd27c0999ef9b8 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Thu, 13 Jul 2023 13:53:21 -0700 Subject: [PATCH 04/12] Works on azure too --- reference-apps/eshop/iac/aws-environment.bicep | 6 +++--- reference-apps/eshop/iac/azure-environment.bicep | 6 +++--- reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep | 3 ++- .../eshop/iac/infra/recipes/azure/azureredis.bicep | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/reference-apps/eshop/iac/aws-environment.bicep b/reference-apps/eshop/iac/aws-environment.bicep index 989a2d5d..0404e63a 100644 --- a/reference-apps/eshop/iac/aws-environment.bicep +++ b/reference-apps/eshop/iac/aws-environment.bicep @@ -15,7 +15,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' compute: { kind: 'kubernetes' resourceId: 'self' - namespace: 'eshop' + namespace: 'aws-eshop' } providers: { aws: { @@ -42,9 +42,9 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } } 'Applications.Link/extenders': { - containersrabbitmq: { + awsrabbitmq: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/awsrabbitmq:edge' } } } diff --git a/reference-apps/eshop/iac/azure-environment.bicep b/reference-apps/eshop/iac/azure-environment.bicep index db41fbf7..c6582c5a 100644 --- a/reference-apps/eshop/iac/azure-environment.bicep +++ b/reference-apps/eshop/iac/azure-environment.bicep @@ -12,7 +12,7 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview compute: { kind: 'kubernetes' resourceId: 'self' - namespace: 'eshop' + namespace: 'azure-eshop' } providers: { azure: { @@ -33,9 +33,9 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview } } 'Applications.Link/extenders': { - containersmessagequeue: { + azurerabbitmq: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/azurerabbitmq:edge' } } } diff --git a/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep index c0bf7488..fa8f52f1 100644 --- a/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep +++ b/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep @@ -42,8 +42,9 @@ output result object = { values: { host: memoryDBCluster.properties.ClusterEndpoint.Address port: memoryDBCluster.properties.ClusterEndpoint.Port + tls: true } secrets: { - url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port}' + url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port},ssl=true' } } diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep index 90732362..6518b695 100644 --- a/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep +++ b/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep @@ -41,6 +41,7 @@ output result object = { host: azureCache.properties.hostName port: azureCache.properties.sslPort username: '' + tls: true } secrets: { #disable-next-line outputs-should-not-contain-secrets From 9905383cd69e53017b2e4309340adfe08280bea6 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Fri, 14 Jul 2023 14:16:40 -0700 Subject: [PATCH 05/12] Removing recipes --- .../eshop/iac/containers-environment.bicep | 2 +- .../iac/infra/recipes/aws/awsmssql.bicep | 72 ---------- .../iac/infra/recipes/aws/awsrabbitmq.bicep | 102 -------------- .../iac/infra/recipes/aws/awsredis.bicep | 50 ------- .../iac/infra/recipes/azure/azuremssql.bicep | 74 ---------- .../infra/recipes/azure/azurerabbitmq.bicep | 102 -------------- .../iac/infra/recipes/azure/azureredis.bicep | 50 ------- .../recipes/containers/containersmssql.bicep | 129 ------------------ .../containers/containersrabbitmq.bicep | 102 -------------- .../recipes/containers/containersredis.bicep | 93 ------------- 10 files changed, 1 insertion(+), 775 deletions(-) delete mode 100644 reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep delete mode 100644 reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep diff --git a/reference-apps/eshop/iac/containers-environment.bicep b/reference-apps/eshop/iac/containers-environment.bicep index 93fe4fd8..68e8c13c 100644 --- a/reference-apps/eshop/iac/containers-environment.bicep +++ b/reference-apps/eshop/iac/containers-environment.bicep @@ -6,7 +6,7 @@ resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepr compute: { kind: 'kubernetes' resourceId: 'self' - namespace: 'eshop' + namespace: 'containers-eshop' } recipes: { 'Applications.Link/sqlDatabases': { diff --git a/reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep deleted file mode 100644 index a6f54843..00000000 --- a/reference-apps/eshop/iac/infra/recipes/aws/awsmssql.bicep +++ /dev/null @@ -1,72 +0,0 @@ -import aws as aws - -@description('Radius-provided object containing information about the resource calling the Recipe') -param context object - -@description('Name of the EKS cluster used for app deployment') -param eksClusterName string - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -@description('Database name') -param database string - -resource eksCluster 'AWS.EKS/Cluster@default' existing = { - alias: eksClusterName - properties: { - Name: eksClusterName - } -} - -var rdsSubnetGroupName = 'eshop-rds-dbsubnetgroup-${uniqueString(context.resource.id)}' -resource rdsDBSubnetGroup 'AWS.RDS/DBSubnetGroup@default' = { - alias: rdsSubnetGroupName - properties: { - DBSubnetGroupName: rdsSubnetGroupName - DBSubnetGroupDescription: rdsSubnetGroupName - SubnetIds: eksCluster.properties.ResourcesVpcConfig.SubnetIds - } -} - -var rdsDBInstanceName = 'eshop-rds-dbinstance-${uniqueString(context.resource.id)}' -resource rdsDBInstance 'AWS.RDS/DBInstance@default' = { - alias: rdsDBInstanceName - properties: { - DBInstanceIdentifier: rdsDBInstanceName - Engine: 'sqlserver-ex' - EngineVersion: '15.00.4153.1.v1' - DBInstanceClass: 'db.t3.large' - AllocatedStorage: '20' - MaxAllocatedStorage: 30 - MasterUsername: adminLogin - MasterUserPassword: adminPassword - // Port: '1433' - DBSubnetGroupName: rdsDBSubnetGroup.properties.DBSubnetGroupName - VPCSecurityGroups: [eksCluster.properties.ClusterSecurityGroupId] - PreferredMaintenanceWindow: 'Mon:00:00-Mon:03:00' - PreferredBackupWindow: '03:00-06:00' - LicenseModel: 'license-included' - Timezone: 'GMT Standard Time' - CharacterSetName: 'Latin1_General_CI_AS' - } -} - -output result object = { - values: { - server: rdsDBInstance.properties.Endpoint.Address - port: 1433 - database: database - username: adminLogin - } - secrets: { - #disable-next-line outputs-should-not-contain-secrets - connectionString: 'Server=tcp:${rdsDBInstance.properties.Endpoint.Address},${rdsDBInstance.properties.Endpoint.Port};Initial Catalog=${database};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - #disable-next-line outputs-should-not-contain-secrets - password: adminPassword - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep deleted file mode 100644 index eb94de83..00000000 --- a/reference-apps/eshop/iac/infra/recipes/aws/awsrabbitmq.bicep +++ /dev/null @@ -1,102 +0,0 @@ -@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') -param context object - -@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') -param queue string = context.resource.name - -@description('Tag to pull for the rabbitmq container image.') -param tag string = '3' - -@description('Memory request for the rabbitmq deployment.') -param memoryRequest string = '256Mi' - -@description('Memory limit for the rabbitmq deployment') -param memoryLimit string = '1024Mi' - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: context.runtime.kubernetes.namespace -} - -var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' -var port = 5672 - -resource rabbitmq 'apps/Deployment@v1' = { - metadata: { - name: uniqueName - } - spec: { - selector: { - matchLabels: { - app: 'rabbitmq' - resource: context.resource.name - } - } - template: { - metadata: { - labels: { - app: 'rabbitmq' - resource: context.resource.name - // Label pods with the application name so `rad run` can find the logs. - 'radius.dev/application': context.application == null ? '' : context.application.name - } - } - spec: { - containers: [ - { - name: 'rabbitmq' - image: 'rabbitmq:${tag}' - ports: [ - { - containerPort: port - } - ] - resources: { - requests: { - memory: memoryRequest - } - limits: { - memory: memoryLimit - } - } - env: [] - } - ] - } - } - } -} - -resource svc 'core/Service@v1' = { - metadata: { - name: uniqueName - labels: { - name: uniqueName - } - } - spec: { - type: 'ClusterIP' - selector: { - app: 'rabbitmq' - resource: context.resource.name - } - ports: [ - { - port: port - } - ] - } -} - -output result object = { - resources: [ - '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' - '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' - ] - values: { - queue: queue - } - secrets: { - connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep b/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep deleted file mode 100644 index fa8f52f1..00000000 --- a/reference-apps/eshop/iac/infra/recipes/aws/awsredis.bicep +++ /dev/null @@ -1,50 +0,0 @@ -import aws as aws - -@description('Radius-provided object containing information about the resource calling the Recipe') -param context object - -@description('Name of the EKS cluster used for app deployment') -param eksClusterName string - -@description('List of subnetIds for the subnet group') -param subnetIds array = [] - -resource eksCluster 'AWS.EKS/Cluster@default' existing = { - alias: eksClusterName - properties: { - Name: eksClusterName - } -} - -param memoryDBSubnetGroupName string = 'eshop-memorydb-subnetgroup-${uniqueString(context.resource.id)}' -resource subnetGroup 'AWS.MemoryDB/SubnetGroup@default' = { - alias: memoryDBSubnetGroupName - properties: { - SubnetGroupName: memoryDBSubnetGroupName - SubnetIds: ((empty(subnetIds)) ? eksCluster.properties.ResourcesVpcConfig.SubnetIds : concat(subnetIds,eksCluster.properties.ResourcesVpcConfig.SubnetIds)) - } -} - -param memoryDBClusterName string = 'eshop-memorydb-cluster-${uniqueString(context.resource.id)}' -resource memoryDBCluster 'AWS.MemoryDB/Cluster@default' = { - alias: memoryDBClusterName - properties: { - ClusterName: memoryDBClusterName - NodeType: 'db.t4g.small' - ACLName: 'open-access' - SecurityGroupIds: [eksCluster.properties.ClusterSecurityGroupId] - SubnetGroupName: subnetGroup.name - NumReplicasPerShard: 0 - } -} - -output result object = { - values: { - host: memoryDBCluster.properties.ClusterEndpoint.Address - port: memoryDBCluster.properties.ClusterEndpoint.Port - tls: true - } - secrets: { - url: '${memoryDBCluster.properties.ClusterEndpoint.Address}:${memoryDBCluster.properties.ClusterEndpoint.Port},ssl=true' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep deleted file mode 100644 index 84400de1..00000000 --- a/reference-apps/eshop/iac/infra/recipes/azure/azuremssql.bicep +++ /dev/null @@ -1,74 +0,0 @@ -@description('Radius-provided object containing information about the resouce calling the Recipe') -param context object - -@description('The geo-location where the resource lives.') -param location string = resourceGroup().location - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -@description('Database name') -param database string - -@description('The type of MSSQL server to deploy. Valid values: (Basic, Standard, Premium)') -@allowed([ - 'Basic' - 'Standard' - 'Premium' -]) -param skuName string = 'Standard' - -@description('The size of the MSSQL server to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).') -@allowed([ - 'Basic' - 'Standard' - 'Premium' -]) -param skuTier string = 'Standard' - -var mssqlPort = 1433 - -resource mssql 'Microsoft.Sql/servers@2021-02-01-preview' = { - name: 'eshop-mssql-${uniqueString(context.resource.id, resourceGroup().id)}' - location: location - properties: { - administratorLogin: adminLogin - administratorLoginPassword: adminPassword - } - - resource firewallAllowEverything 'firewallRules' = { - name: 'firewall-allow-everything' - properties: { - startIpAddress: '0.0.0.0' - endIpAddress: '255.255.255.255' - } - } - - resource db 'databases' = { - name: database - location: location - sku: { - name: skuName - tier: skuTier - } - } -} - -output result object = { - values: { - server: mssql.properties.fullyQualifiedDomainName - port: mssqlPort - database: mssql::db.name - username: adminLogin - } - secrets: { - #disable-next-line outputs-should-not-contain-secrets - password: adminPassword - #disable-next-line outputs-should-not-contain-secrets - connectionString: 'Server=tcp:${mssql.properties.fullyQualifiedDomainName},${mssqlPort};Initial Catalog=${mssql::db.name};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep deleted file mode 100644 index eb94de83..00000000 --- a/reference-apps/eshop/iac/infra/recipes/azure/azurerabbitmq.bicep +++ /dev/null @@ -1,102 +0,0 @@ -@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') -param context object - -@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') -param queue string = context.resource.name - -@description('Tag to pull for the rabbitmq container image.') -param tag string = '3' - -@description('Memory request for the rabbitmq deployment.') -param memoryRequest string = '256Mi' - -@description('Memory limit for the rabbitmq deployment') -param memoryLimit string = '1024Mi' - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: context.runtime.kubernetes.namespace -} - -var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' -var port = 5672 - -resource rabbitmq 'apps/Deployment@v1' = { - metadata: { - name: uniqueName - } - spec: { - selector: { - matchLabels: { - app: 'rabbitmq' - resource: context.resource.name - } - } - template: { - metadata: { - labels: { - app: 'rabbitmq' - resource: context.resource.name - // Label pods with the application name so `rad run` can find the logs. - 'radius.dev/application': context.application == null ? '' : context.application.name - } - } - spec: { - containers: [ - { - name: 'rabbitmq' - image: 'rabbitmq:${tag}' - ports: [ - { - containerPort: port - } - ] - resources: { - requests: { - memory: memoryRequest - } - limits: { - memory: memoryLimit - } - } - env: [] - } - ] - } - } - } -} - -resource svc 'core/Service@v1' = { - metadata: { - name: uniqueName - labels: { - name: uniqueName - } - } - spec: { - type: 'ClusterIP' - selector: { - app: 'rabbitmq' - resource: context.resource.name - } - ports: [ - { - port: port - } - ] - } -} - -output result object = { - resources: [ - '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' - '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' - ] - values: { - queue: queue - } - secrets: { - connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep b/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep deleted file mode 100644 index 6518b695..00000000 --- a/reference-apps/eshop/iac/infra/recipes/azure/azureredis.bicep +++ /dev/null @@ -1,50 +0,0 @@ -@description('Radius-provided object containing information about the resouce calling the Recipe') -param context object - -@description('The geo-location where the resource lives.') -param location string = resourceGroup().location - -@description('The size of the Redis cache to deploy. Valid values: for C (Basic/Standard) family (0, 1, 2, 3, 4, 5, 6), for P (Premium) family (1, 2, 3, 4).') -@minValue(0) -@maxValue(6) -param skuCapacity int = 0 - -@description('The SKU family to use. Valid values: (C, P). (C = Basic/Standard, P = Premium).') -@allowed([ - 'C' - 'P' -]) -param skuFamily string = 'C' - -@description('The type of Redis cache to deploy. Valid values: (Basic, Standard, Premium)') -@allowed([ - 'Basic' - 'Standard' - 'Premium' -]) -param skuName string = 'Basic' - -resource azureCache 'Microsoft.Cache/redis@2022-06-01' = { - name: 'eshop-cache-${uniqueString(context.resource.id, resourceGroup().id)}' - location: location - properties: { - sku: { - capacity: skuCapacity - family: skuFamily - name: skuName - } - } -} - -output result object = { - values: { - host: azureCache.properties.hostName - port: azureCache.properties.sslPort - username: '' - tls: true - } - secrets: { - #disable-next-line outputs-should-not-contain-secrets - password: azureCache.listKeys().primaryKey - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep deleted file mode 100644 index ca327615..00000000 --- a/reference-apps/eshop/iac/infra/recipes/containers/containersmssql.bicep +++ /dev/null @@ -1,129 +0,0 @@ -@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') -param context object - -@description('Name of the SQL database. Defaults to the name of the Radius SQL resource.') -param database string = context.resource.name - -@description('SQL administrator username') -param adminLogin string - -@description('SQL administrator password') -@secure() -param adminPassword string - -@description('Tag to pull for the azure-sql-edge container image.') -param tag string = '1.0.7' - -@description('Memory request for the azure-sql-edge deployment.') -param memoryRequest string = '512Mi' - -@description('Memory limit for the azure-sql-edge deployment') -param memoryLimit string = '1024Mi' - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: context.runtime.kubernetes.namespace -} - -var uniqueName = 'sql-${uniqueString(context.resource.id)}' -var port = 1433 - -resource sql 'apps/Deployment@v1' = { - metadata: { - name: uniqueName - } - spec: { - selector: { - matchLabels: { - app: 'sql' - resource: context.resource.name - } - } - template: { - metadata: { - labels: { - app: 'sql' - resource: context.resource.name - - // Label pods with the application name so `rad run` can find the logs. - 'radius.dev/application': context.application == null ? '' : context.application.name - } - } - spec: { - containers: [ - { - // This container is the running sql instance. - name: 'sql' - image: 'mcr.microsoft.com/azure-sql-edge:${tag}' - ports: [ - { - containerPort: port - } - ] - resources: { - requests: { - memory: memoryRequest - } - limits: { - memory: memoryLimit - } - } - env: [ - { - name: 'ACCEPT_EULA' - value: '1' - } - { - name: 'MSSQL_SA_PASSWORD' - value: adminPassword - } - ] - } - ] - } - } - } -} - -resource svc 'core/Service@v1' = { - metadata: { - name: uniqueName - labels: { - name: uniqueName - } - } - spec: { - type: 'ClusterIP' - selector: { - app: 'sql' - resource: context.resource.name - } - ports: [ - { - port: port - } - ] - } -} - -output result object = { - // This workaround is needed because the deployment engine omits Kubernetes resources from its output. - // This allows Kubernetes resources to be cleaned up when the resource is deleted. - // Once this gap is addressed, users won't need to do this. - resources: [ - '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' - '/planes/kubernetes/local/namespaces/${sql.metadata.namespace}/providers/apps/Deployment/${sql.metadata.name}' - ] - values: { - server: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' - port: port - database: database - username: adminLogin - } - secrets: { - #disable-next-line outputs-should-not-contain-secrets - password: adminPassword - #disable-next-line outputs-should-not-contain-secrets - connectionString: 'Server=tcp:${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local,${port};Initial Catalog=${database};User Id=${adminLogin};Password=${adminPassword};Encrypt=false' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep deleted file mode 100644 index eb94de83..00000000 --- a/reference-apps/eshop/iac/infra/recipes/containers/containersrabbitmq.bicep +++ /dev/null @@ -1,102 +0,0 @@ -@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') -param context object - -@description('Name of the queue. Defaults to the name of the Radius RabbitMQ resource.') -param queue string = context.resource.name - -@description('Tag to pull for the rabbitmq container image.') -param tag string = '3' - -@description('Memory request for the rabbitmq deployment.') -param memoryRequest string = '256Mi' - -@description('Memory limit for the rabbitmq deployment') -param memoryLimit string = '1024Mi' - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: context.runtime.kubernetes.namespace -} - -var uniqueName = 'rabbitmq-${uniqueString(context.resource.id)}' -var port = 5672 - -resource rabbitmq 'apps/Deployment@v1' = { - metadata: { - name: uniqueName - } - spec: { - selector: { - matchLabels: { - app: 'rabbitmq' - resource: context.resource.name - } - } - template: { - metadata: { - labels: { - app: 'rabbitmq' - resource: context.resource.name - // Label pods with the application name so `rad run` can find the logs. - 'radius.dev/application': context.application == null ? '' : context.application.name - } - } - spec: { - containers: [ - { - name: 'rabbitmq' - image: 'rabbitmq:${tag}' - ports: [ - { - containerPort: port - } - ] - resources: { - requests: { - memory: memoryRequest - } - limits: { - memory: memoryLimit - } - } - env: [] - } - ] - } - } - } -} - -resource svc 'core/Service@v1' = { - metadata: { - name: uniqueName - labels: { - name: uniqueName - } - } - spec: { - type: 'ClusterIP' - selector: { - app: 'rabbitmq' - resource: context.resource.name - } - ports: [ - { - port: port - } - ] - } -} - -output result object = { - resources: [ - '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' - '/planes/kubernetes/local/namespaces/${rabbitmq.metadata.namespace}/providers/apps/Deployment/${rabbitmq.metadata.name}' - ] - values: { - queue: queue - } - secrets: { - connectionString: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' - } -} diff --git a/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep b/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep deleted file mode 100644 index 974727b4..00000000 --- a/reference-apps/eshop/iac/infra/recipes/containers/containersredis.bicep +++ /dev/null @@ -1,93 +0,0 @@ -@description('Information about what resource is calling this Recipe. Generated by Radius. For more information visit https://docs.radapp.dev/operations/custom-recipes/') -param context object - -import kubernetes as kubernetes { - kubeConfig: '' - namespace: context.runtime.kubernetes.namespace -} - -resource redis 'apps/Deployment@v1' = { - metadata: { - name: 'redis-${uniqueString(context.resource.id)}' - } - spec: { - selector: { - matchLabels: { - app: 'redis' - resource: context.resource.name - } - } - template: { - metadata: { - labels: { - app: 'redis' - resource: context.resource.name - - // Label pods with the application name so `rad run` can find the logs. - 'radius.dev/application': context.application == null ? '' : context.application.name - } - } - spec: { - containers: [ - { - // This container is the running redis instance. - name: 'redis' - image: 'redis' - ports: [ - { - containerPort: 6379 - } - ] - } - { - // This container will connect to redis and stream logs to stdout for aid in development. - name: 'redis-monitor' - image: 'redis' - args: [ - 'redis-cli' - '-h' - 'localhost' - 'MONITOR' - ] - } - ] - } - } - } -} - -resource svc 'core/Service@v1' = { - metadata: { - name: 'redis-${uniqueString(context.resource.id)}' - } - spec: { - type: 'ClusterIP' - selector: { - app: 'redis' - resource: context.resource.name - } - ports: [ - { - port: 6379 - } - ] - } -} - -output result object = { - // This workaround is needed because the deployment engine omits Kubernetes resources from its output. - // This allows Kubernetes resources to be cleaned up when the resource is deleted. - // Once this gap is addressed, users won't need to do this. - resources: [ - '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' - '/planes/kubernetes/local/namespaces/${redis.metadata.namespace}/providers/apps/Deployment/${redis.metadata.name}' - ] - values: { - host: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' - port: 6379 - } - secrets: { - password: '' - url: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local:6379,abortConnect=False' - } -} From 5109f135eaaa81c95c8884302cab1ac9fc629d52 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Wed, 26 Jul 2023 14:00:40 -0700 Subject: [PATCH 06/12] yes --- reference-apps/eshop/iac/aws-environment.bicep | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reference-apps/eshop/iac/aws-environment.bicep b/reference-apps/eshop/iac/aws-environment.bicep index 0404e63a..ce51ce34 100644 --- a/reference-apps/eshop/iac/aws-environment.bicep +++ b/reference-apps/eshop/iac/aws-environment.bicep @@ -26,7 +26,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' 'Applications.Link/sqlDatabases': { awsmssql: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/awsmssql:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/aws/sqldatabases:edge' parameters: { eksClusterName: eksClusterName } @@ -35,16 +35,17 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' 'Applications.Link/redisCaches': { awsredis: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/awsredis:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/aws/rediscaches:edge' parameters: { eksClusterName: eksClusterName } } } + // Temporarily using containerized rabbitmq until we can use SQS 'Applications.Link/extenders': { awsrabbitmq: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/awsrabbitmq:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/dev/rabbitmqmessagequeues:edge' } } } From 85fa82767002abb36b63797aff55780fde666d5b Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Thu, 27 Jul 2023 13:41:05 -0700 Subject: [PATCH 07/12] Working azure servicebus --- .../aws.bicep} | 8 ++-- .../azure.bicep} | 16 ++++--- .../containers.bicep} | 12 ++--- reference-apps/eshop/iac/eshop.bicep | 32 ++++++------- reference-apps/eshop/iac/infra/infra.bicep | 47 +++++++++++++------ .../iac/{services => infra}/networking.bicep | 0 .../eshop/iac/services/basket.bicep | 8 +++- .../eshop/iac/services/catalog.bicep | 8 +++- .../eshop/iac/services/ordering.bicep | 12 +++-- .../eshop/iac/services/payment.bicep | 8 +++- .../eshop/iac/services/webhooks.bicep | 8 +++- .../eshop/iac/services/webshopping.bicep | 13 ----- 12 files changed, 98 insertions(+), 74 deletions(-) rename reference-apps/eshop/iac/{aws-environment.bicep => environments/aws.bicep} (88%) rename reference-apps/eshop/iac/{azure-environment.bicep => environments/azure.bicep} (78%) rename reference-apps/eshop/iac/{containers-environment.bicep => environments/containers.bicep} (61%) rename reference-apps/eshop/iac/{services => infra}/networking.bicep (100%) diff --git a/reference-apps/eshop/iac/aws-environment.bicep b/reference-apps/eshop/iac/environments/aws.bicep similarity index 88% rename from reference-apps/eshop/iac/aws-environment.bicep rename to reference-apps/eshop/iac/environments/aws.bicep index ce51ce34..a028c9c5 100644 --- a/reference-apps/eshop/iac/aws-environment.bicep +++ b/reference-apps/eshop/iac/environments/aws.bicep @@ -24,7 +24,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } recipes: { 'Applications.Link/sqlDatabases': { - awsmssql: { + sqldatabase: { templateKind: 'bicep' templatePath: 'willsmithradius.azurecr.io/recipes/aws/sqldatabases:edge' parameters: { @@ -33,7 +33,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } } 'Applications.Link/redisCaches': { - awsredis: { + rediscache: { templateKind: 'bicep' templatePath: 'willsmithradius.azurecr.io/recipes/aws/rediscaches:edge' parameters: { @@ -43,9 +43,9 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } // Temporarily using containerized rabbitmq until we can use SQS 'Applications.Link/extenders': { - awsrabbitmq: { + rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/dev/rabbitmqmessagequeues:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/azure-environment.bicep b/reference-apps/eshop/iac/environments/azure.bicep similarity index 78% rename from reference-apps/eshop/iac/azure-environment.bicep rename to reference-apps/eshop/iac/environments/azure.bicep index c6582c5a..375cea8f 100644 --- a/reference-apps/eshop/iac/azure-environment.bicep +++ b/reference-apps/eshop/iac/environments/azure.bicep @@ -21,21 +21,25 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview } recipes: { 'Applications.Link/sqlDatabases': { - azuremssql: { + sqldatabase: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azuremssql:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/azure/sqldatabases:edge' } } 'Applications.Link/redisCaches': { - azureredis: { + rediscache: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azureredis:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/azure/rediscaches:edge' } } 'Applications.Link/extenders': { - azurerabbitmq: { + servicebus: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azurerabbitmq:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/azure/servicebus:edge' + } + rabbitmqmessagequeue: { + templateKind: 'bicep' + templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/containers-environment.bicep b/reference-apps/eshop/iac/environments/containers.bicep similarity index 61% rename from reference-apps/eshop/iac/containers-environment.bicep rename to reference-apps/eshop/iac/environments/containers.bicep index 68e8c13c..3ec52b08 100644 --- a/reference-apps/eshop/iac/containers-environment.bicep +++ b/reference-apps/eshop/iac/environments/containers.bicep @@ -10,21 +10,21 @@ resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepr } recipes: { 'Applications.Link/sqlDatabases': { - containersmssql: { + sqldatabase: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/containersmssql:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/sqldatabases:edge' } } 'Applications.Link/redisCaches': { - containersredis: { + rediscache: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/containersredis:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rediscaches:edge' } } 'Applications.Link/extenders': { - containersrabbitmq: { + rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/containersrabbitmq:edge' + templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index 76a74072..9cbe9e57 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -8,22 +8,14 @@ param appName string = 'eshop' @description('Radius environment ID. Set automatically by Radius') param environment string -@description('What type of infrastructure to use. Options are "containers", "azure", or "aws". Defaults to containers') -@allowed([ - 'containers' - 'azure' - 'aws' -]) -param platform string = 'containers' - -@description('SQL administrator username') -param adminLogin string = (platform == 'containers') ? 'SA' : 'sqladmin' +@description('SQL administrator username. Defaults to "SA"') +param adminLogin string = 'SA' @description('SQL administrator password') @secure() param adminPassword string = newGuid() -@description('What container orchestrator to use. Defaults to K8S') +@description('Container orchestrator to use. Defaults to "K8S') @allowed([ 'K8S' ]) @@ -32,28 +24,28 @@ param ORCHESTRATOR_TYPE string = 'K8S' @description('Optional App Insights Key') param APPLICATION_INSIGHTS_KEY string = '' -@description('Use Azure storage for custom resource images. Defaults to False') +@description('Use Azure storage for custom resource images. Defaults to "False"') @allowed([ 'True' 'False' ]) param AZURESTORAGEENABLED string = 'False' -@description('Use Azure Service Bus for messaging') +@description('Use Azure Service Bus for messaging. Defaults to "False"') @allowed([ 'True' 'False' ]) param AZURESERVICEBUSENABLED string = 'False' -@description('Use dev spaces. Defaults to False') +@description('Use dev spaces. Defaults to "False"') @allowed([ 'True' 'False' ]) param ENABLEDEVSPACES string = 'False' -@description('Container image tag to use for eshop images. Defaults to linux-dotnet7') +@description('Container image tag to use for eshop images. Defaults to "linux-dotnet7"') param TAG string = 'linux-dotnet7' // Application -------------------------------------------------------- @@ -70,17 +62,17 @@ resource eshop 'Applications.Core/applications@2022-03-15-privatepreview' = { module infra 'infra/infra.bicep' = { name: 'infra' params: { - platform: platform application: eshop.id environment: environment adminLogin: adminLogin adminPassword: adminPassword + AZURESERVICEBUSENABLED: AZURESERVICEBUSENABLED } } // Networking ---------------------------------------------------------- -module networking 'services/networking.bicep' = { +module networking 'infra/networking.bicep' = { name: 'networking' params: { application: eshop.id @@ -103,6 +95,7 @@ module basket 'services/basket.bicep' = { rabbitmqName: infra.outputs.rabbitmq redisBasketName: infra.outputs.redisBasket TAG: TAG + serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' } } @@ -120,6 +113,7 @@ module catalog 'services/catalog.bicep' = { rabbitmqName: infra.outputs.rabbitmq sqlCatalogDbName: infra.outputs.sqlCatalogDb TAG: TAG + serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' } } @@ -162,6 +156,7 @@ module ordering 'services/ordering.bicep' = { redisKeystoreName: infra.outputs.redisKeystore sqlOrderingDbName: infra.outputs.sqlOrderingDb TAG: TAG + serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' } } @@ -175,6 +170,7 @@ module payment 'services/payment.bicep' = { paymentHttpName: networking.outputs.paymentHttp rabbitmqName: infra.outputs.rabbitmq TAG: TAG + serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' } } @@ -217,6 +213,7 @@ module webhooks 'services/webhooks.bicep' = { TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp + serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' } } @@ -234,7 +231,6 @@ module webshopping 'services/webshopping.bicep' = { orderingGrpcName: networking.outputs.orderingGrpc orderingHttpName: networking.outputs.basketHttp paymentHttpName: networking.outputs.paymentHttp - rabbitmqName: infra.outputs.rabbitmq TAG: TAG webshoppingaggHttpName: networking.outputs.webshoppingaggHttp webshoppingapigwHttp2Name: networking.outputs.webshoppingapigwHttp2 diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index 9ed82704..920bbfc5 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -1,13 +1,5 @@ import radius as rad -@description('What type of infrastructure to use. Options are "containers", "azure", or "aws"') -@allowed([ - 'containers' - 'azure' - 'aws' -]) -param platform string - @description('Radius environment ID') param environment string @@ -21,6 +13,13 @@ param adminLogin string @secure() param adminPassword string +@description('Use Azure Service Bus for messaging. Defaults to "False"') +@allowed([ + 'True' + 'False' +]) +param AZURESERVICEBUSENABLED string + // Links --------------------------------------------------------------- resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { @@ -29,7 +28,7 @@ resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: '${platform}mssql' + name: 'sqldatabase' parameters: { database: 'IdentityDb' adminLogin: adminLogin @@ -45,7 +44,7 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: '${platform}mssql' + name: 'sqldatabase' parameters: { database: 'CatalogDb' adminLogin: adminLogin @@ -61,7 +60,7 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: '${platform}mssql' + name: 'sqldatabase' parameters: { database: 'OrderingDb' adminLogin: adminLogin @@ -77,7 +76,7 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview application: application environment: environment recipe: { - name: '${platform}mssql' + name: 'sqldatabase' parameters: { database: 'WebhooksDb' adminLogin: adminLogin @@ -93,7 +92,7 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' application: application environment: environment recipe: { - name: '${platform}redis' + name: 'rediscache' } } } @@ -104,7 +103,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = application: application environment: environment recipe: { - name: '${platform}redis' + name: 'rediscache' } } } @@ -115,7 +114,22 @@ resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { application: application environment: environment recipe: { - name: '${platform}rabbitmq' + name: 'rabbitmqmessagequeue' + } + } +} + +resource servicebus 'Applications.Link/extenders@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'True') { + name: 'servicebus' + properties: { + application: application + environment: environment + recipe: { + name: 'servicebus' + parameters: { + topicName: 'eshop_event_bus' + subscriptions: ['Basket', 'Catalog', 'Ordering', 'GracePeriod', 'Payment', 'backgroundtasks', 'Ordering.signalrhub', 'Webhooks'] + } } } } @@ -142,3 +156,6 @@ output redisBasket string = redisBasket.name @description('The name of the RabbitMQ Link') output rabbitmq string = rabbitmq.name + +@description('The service bus connection string') +output serviceBusAuthConnectionString string = servicebus.secrets('connectionString') diff --git a/reference-apps/eshop/iac/services/networking.bicep b/reference-apps/eshop/iac/infra/networking.bicep similarity index 100% rename from reference-apps/eshop/iac/services/networking.bicep rename to reference-apps/eshop/iac/infra/networking.bicep diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index 4eea90a2..e446ba79 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -22,7 +22,7 @@ param ORCHESTRATOR_TYPE string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string = 'False' +param AZURESERVICEBUSENABLED string @description('The name of the Radius Gateway') param gatewayName string @@ -42,6 +42,10 @@ param redisBasketName string @description('The name of the RabbitMQ Link') param rabbitmqName string +@description('The connection string of the Azure Service Bus') +@secure() +param serviceBusConnectionString string + // Container ------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/basket-api @@ -62,7 +66,7 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: redisBasket.connectionString() - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index 6f8d0396..e6c21860 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -26,7 +26,7 @@ param AZURESTORAGEENABLED string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string = 'False' +param AZURESERVICEBUSENABLED string @description('Container image tag to use for eshop images') param TAG string @@ -46,6 +46,10 @@ param rabbitmqName string @description('The name of the Catalog SQL Link') param sqlCatalogDbName string +@description('The connection string of the Azure Service Bus') +@secure() +param serviceBusConnectionString string + // VARIABLES ----------------------------------------------------------------------------------- var PICBASEURL = '${gateway.properties.url}/webshoppingapigw/c/api/v1/catalog/items/[0]/pic' @@ -71,7 +75,7 @@ resource catalog 'Applications.Core/containers@2022-03-15-privatepreview' = { ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlCatalogDb.connectionString() - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString } ports: { http: { diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index b1ad18e3..50137f6c 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -19,7 +19,7 @@ param APPLICATION_INSIGHTS_KEY string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string = 'False' +param AZURESERVICEBUSENABLED string @description('Container image tag to use for eshop images') param TAG string @@ -57,6 +57,10 @@ param rabbitmqName string @description('Name of the Ordering SQL Link') param sqlOrderingDbName string +@description('The connection string of the Azure Service Bus') +@secure() +param serviceBusConnectionString string + // CONTAINERS ------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/ordering-api @@ -81,7 +85,7 @@ resource ordering 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' PORT: '80' ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -128,7 +132,7 @@ resource orderbgtasks 'Applications.Core/containers@2022-03-15-privatepreview' = OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString } ports: { http: { @@ -161,7 +165,7 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString SignalrStoreConnectionString: redisKeystore.connectionString() identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' diff --git a/reference-apps/eshop/iac/services/payment.bicep b/reference-apps/eshop/iac/services/payment.bicep index 04d310f9..3ee8eaac 100644 --- a/reference-apps/eshop/iac/services/payment.bicep +++ b/reference-apps/eshop/iac/services/payment.bicep @@ -19,7 +19,7 @@ param APPLICATION_INSIGHTS_KEY string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string = 'False' +param AZURESERVICEBUSENABLED string @description('Container image tag to use for eshop images') param TAG string @@ -30,6 +30,10 @@ param paymentHttpName string @description('The name of the RabbitMQ Link') param rabbitmqName string +@description('The connection string of the Azure Service Bus') +@secure() +param serviceBusConnectionString string + // CONTAINERS --------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/payment-api @@ -45,7 +49,7 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { 'Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ': 'Verbose' OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString } ports: { http: { diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 2fc62c28..49bc781c 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -16,7 +16,7 @@ param ORCHESTRATOR_TYPE string 'True' 'False' ]) -param AZURESERVICEBUSENABLED string = 'False' +param AZURESERVICEBUSENABLED string @description('Container image tag to use for eshop images. Defaults to linux-dotnet7') param TAG string @@ -39,6 +39,10 @@ param sqlWebhooksDbName string @description('The name of the RabbitMQ Link') param rabbitmqName string +@description('The connection string of the Azure Service Bus') +@secure() +param serviceBusConnectionString string + // CONTAINERS ----------------------------------------------------------- // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/webhooks-api @@ -55,7 +59,7 @@ resource webhooks 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlWebhooksDb.connectionString() - EventBusConnection: rabbitmq.secrets('connectionString') + EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/webshopping.bicep b/reference-apps/eshop/iac/services/webshopping.bicep index c8e35957..93afb086 100644 --- a/reference-apps/eshop/iac/services/webshopping.bicep +++ b/reference-apps/eshop/iac/services/webshopping.bicep @@ -50,9 +50,6 @@ param webshoppingapigwHttp2Name string @description('Web Shopping Aggregator Http Route name') param webshoppingaggHttpName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - // Based on https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/deploy/k8s/helm/webshoppingagg resource webshoppingagg 'Applications.Core/containers@2022-03-15-privatepreview' = { name: 'webshoppingagg' @@ -88,10 +85,6 @@ resource webshoppingagg 'Applications.Core/containers@2022-03-15-privatepreview' } } connections: { - rabbitmq: { - source: rabbitmq.id - disableDefaultEnvVars: true - } identity: { source: identityHttp.id disableDefaultEnvVars: true @@ -183,9 +176,3 @@ resource webshoppingapigwHttp 'Applications.Core/httpRoutes@2022-03-15-privatepr resource webshoppingapigwHttp2 'Applications.Core/httpRoutes@2022-03-15-privatepreview' existing = { name: webshoppingapigwHttp2Name } - -// LINKS -------------------------------------------------------- - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} From 1c2935348968f1a470505b280c06da094c1212e1 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Thu, 27 Jul 2023 14:55:01 -0700 Subject: [PATCH 08/12] Event bus --- .../eshop/iac/environments/azure.bicep | 4 ---- reference-apps/eshop/iac/eshop.bicep | 15 +++++---------- reference-apps/eshop/iac/infra/infra.bicep | 9 ++++++--- reference-apps/eshop/iac/services/basket.bicep | 13 +++---------- reference-apps/eshop/iac/services/catalog.bicep | 13 +++---------- .../eshop/iac/services/ordering.bicep | 17 +++++------------ reference-apps/eshop/iac/services/payment.bicep | 15 +++------------ .../eshop/iac/services/webhooks.bicep | 13 +++---------- 8 files changed, 28 insertions(+), 71 deletions(-) diff --git a/reference-apps/eshop/iac/environments/azure.bicep b/reference-apps/eshop/iac/environments/azure.bicep index 375cea8f..f3a1b6d5 100644 --- a/reference-apps/eshop/iac/environments/azure.bicep +++ b/reference-apps/eshop/iac/environments/azure.bicep @@ -37,10 +37,6 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview templateKind: 'bicep' templatePath: 'willsmithradius.azurecr.io/recipes/azure/servicebus:edge' } - rabbitmqmessagequeue: { - templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' - } } } } diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index 9cbe9e57..090496d3 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -92,10 +92,9 @@ module basket 'services/basket.bicep' = { identityHttpName: networking.outputs.identityHttp basketHttpName: networking.outputs.basketHttp basketGrpcName: networking.outputs.basketGrpc - rabbitmqName: infra.outputs.rabbitmq redisBasketName: infra.outputs.redisBasket TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' + eventbusConnectionString: infra.outputs.eventbusConnectionString } } @@ -110,10 +109,9 @@ module catalog 'services/catalog.bicep' = { catalogHttpName: networking.outputs.catalogHttp gatewayName: networking.outputs.gateway ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE - rabbitmqName: infra.outputs.rabbitmq sqlCatalogDbName: infra.outputs.sqlCatalogDb TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' + eventbusConnectionString: infra.outputs.eventbusConnectionString } } @@ -152,11 +150,10 @@ module ordering 'services/ordering.bicep' = { orderingGrpcName: networking.outputs.orderingGrpc orderingHttpName: networking.outputs.orderingHttp orderingsignalrhubHttpName: networking.outputs.orderingsignalrhubHttp - rabbitmqName: infra.outputs.rabbitmq redisKeystoreName: infra.outputs.redisKeystore sqlOrderingDbName: infra.outputs.sqlOrderingDb TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' + eventbusConnectionString: infra.outputs.eventbusConnectionString } } @@ -168,9 +165,8 @@ module payment 'services/payment.bicep' = { AZURESERVICEBUSENABLED: AZURESERVICEBUSENABLED ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE paymentHttpName: networking.outputs.paymentHttp - rabbitmqName: infra.outputs.rabbitmq TAG: TAG - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' + eventbusConnectionString: infra.outputs.eventbusConnectionString } } @@ -208,12 +204,11 @@ module webhooks 'services/webhooks.bicep' = { gatewayName: networking.outputs.gateway identityHttpName: networking.outputs.identityHttp ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE - rabbitmqName: infra.outputs.rabbitmq sqlWebhooksDbName: infra.outputs.sqlWebhooksDb TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp - serviceBusConnectionString: (AZURESERVICEBUSENABLED == 'True') ? infra.outputs.serviceBusAuthConnectionString : '' + eventbusConnectionString: infra.outputs.eventbusConnectionString } } diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index 920bbfc5..fb77afef 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -108,7 +108,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = } } -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = { +resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'False') { name: 'rabbitmq' properties: { application: application @@ -157,5 +157,8 @@ output redisBasket string = redisBasket.name @description('The name of the RabbitMQ Link') output rabbitmq string = rabbitmq.name -@description('The service bus connection string') -output serviceBusAuthConnectionString string = servicebus.secrets('connectionString') +@description('The name of the Service Bus Link') +output servicebus string = servicebus.name + +@description('Event Bus connection string') +output eventbusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.secrets('connectionString') : rabbitmq.secrets('connectionString') diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index e446ba79..b380da60 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -39,12 +39,9 @@ param basketGrpcName string @description('The name of the Redis Basket Link') param redisBasketName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - -@description('The connection string of the Azure Service Bus') +@description('The connection string for the event bus') @secure() -param serviceBusConnectionString string +param eventbusConnectionString string // Container ------------------------------------- @@ -66,7 +63,7 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: redisBasket.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -117,7 +114,3 @@ resource basketGrpc 'Applications.Core/httpRoutes@2022-03-15-privatepreview' exi resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { name: redisBasketName } - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index e6c21860..f2277152 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -40,15 +40,12 @@ param catalogHttpName string @description('The name of the Catalog gRPC Route') param catalogGrpcName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - @description('The name of the Catalog SQL Link') param sqlCatalogDbName string -@description('The connection string of the Azure Service Bus') +@description('The connection string for the event bus') @secure() -param serviceBusConnectionString string +param eventbusConnectionString string // VARIABLES ----------------------------------------------------------------------------------- @@ -75,7 +72,7 @@ resource catalog 'Applications.Core/containers@2022-03-15-privatepreview' = { ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlCatalogDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString } ports: { http: { @@ -115,7 +112,3 @@ resource catalogGrpc 'Applications.Core/httpRoutes@2022-03-15-privatepreview' ex resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlCatalogDbName } - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index 50137f6c..7642e948 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -51,15 +51,12 @@ param orderbgtasksHttpName string @description('Name of the Keystore Redis Link') param redisKeystoreName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - @description('Name of the Ordering SQL Link') param sqlOrderingDbName string -@description('The connection string of the Azure Service Bus') +@description('The connection string for the event bus') @secure() -param serviceBusConnectionString string +param eventbusConnectionString string // CONTAINERS ------------------------------------------------------- @@ -85,7 +82,7 @@ resource ordering 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' PORT: '80' ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -132,7 +129,7 @@ resource orderbgtasks 'Applications.Core/containers@2022-03-15-privatepreview' = OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString } ports: { http: { @@ -165,7 +162,7 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString SignalrStoreConnectionString: redisKeystore.connectionString() identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' @@ -245,7 +242,3 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlOrderingDbName } - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} diff --git a/reference-apps/eshop/iac/services/payment.bicep b/reference-apps/eshop/iac/services/payment.bicep index 3ee8eaac..0cec4542 100644 --- a/reference-apps/eshop/iac/services/payment.bicep +++ b/reference-apps/eshop/iac/services/payment.bicep @@ -27,12 +27,9 @@ param TAG string @description('Name of the Payment HTTP route') param paymentHttpName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - -@description('The connection string of the Azure Service Bus') +@description('The connection string for the event bus') @secure() -param serviceBusConnectionString string +param eventbusConnectionString string // CONTAINERS --------------------------------------------------------- @@ -49,7 +46,7 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { 'Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ': 'Verbose' OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString } ports: { http: { @@ -66,9 +63,3 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { resource paymentHttp 'Applications.Core/httpRoutes@2022-03-15-privatepreview' existing = { name: paymentHttpName } - -// LINKS ----------------------------------------------------------- - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 49bc781c..8ab5017a 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -36,12 +36,9 @@ param webhooksclientHttpName string @description('The name of the Webhooks SQL Link') param sqlWebhooksDbName string -@description('The name of the RabbitMQ Link') -param rabbitmqName string - -@description('The connection string of the Azure Service Bus') +@description('The connection string for the event bus') @secure() -param serviceBusConnectionString string +param eventbusConnectionString string // CONTAINERS ----------------------------------------------------------- @@ -59,7 +56,7 @@ resource webhooks 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlWebhooksDb.connectionString() - EventBusConnection: (AZURESERVICEBUSENABLED == 'False') ? rabbitmq.secrets('connectionString') : serviceBusConnectionString + EventBusConnection: eventbusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -142,7 +139,3 @@ resource webhooksclientHttp 'Applications.Core/httpRoutes@2022-03-15-privateprev resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlWebhooksDbName } - -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' existing = { - name: rabbitmqName -} From d95b35ca9ad104c0f76c66db02cda155e7f77b1f Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 15 Aug 2023 08:19:43 -0700 Subject: [PATCH 09/12] testing --- reference-apps/eshop/iac/environments/aws.bicep | 10 +++++----- reference-apps/eshop/iac/environments/azure.bicep | 6 +++--- reference-apps/eshop/iac/environments/containers.bicep | 8 ++++---- reference-apps/eshop/iac/eshop.bicep | 2 +- reference-apps/eshop/iac/infra/infra.bicep | 7 ++++--- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/reference-apps/eshop/iac/environments/aws.bicep b/reference-apps/eshop/iac/environments/aws.bicep index a028c9c5..7dc4e532 100644 --- a/reference-apps/eshop/iac/environments/aws.bicep +++ b/reference-apps/eshop/iac/environments/aws.bicep @@ -26,7 +26,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' 'Applications.Link/sqlDatabases': { sqldatabase: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/aws/sqldatabases:edge' + templatePath: 'radiusdev.azurecr.io/recipes/aws/sqldatabases:pr-29' parameters: { eksClusterName: eksClusterName } @@ -35,17 +35,17 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' 'Applications.Link/redisCaches': { rediscache: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/aws/rediscaches:edge' + templatePath: 'radius.azurecr.io/recipes/aws/rediscaches:edge' parameters: { eksClusterName: eksClusterName } } } - // Temporarily using containerized rabbitmq until we can use SQS - 'Applications.Link/extenders': { + // Temporarily using containerized rabbitmq until we can use SQS or AmazonMQ + 'Applications.Link/rabbitMQMessageQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/environments/azure.bicep b/reference-apps/eshop/iac/environments/azure.bicep index f3a1b6d5..b0525398 100644 --- a/reference-apps/eshop/iac/environments/azure.bicep +++ b/reference-apps/eshop/iac/environments/azure.bicep @@ -23,19 +23,19 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview 'Applications.Link/sqlDatabases': { sqldatabase: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azure/sqldatabases:edge' + templatePath: 'radius.azurecr.io/recipes/azure/sqldatabases:latest' } } 'Applications.Link/redisCaches': { rediscache: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azure/rediscaches:edge' + templatePath: 'radius.azurecr.io/recipes/azure/rediscaches:latest' } } 'Applications.Link/extenders': { servicebus: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/azure/servicebus:edge' + templatePath: 'radius.azurecr.io/recipes/azure/extender-servicebus:latest' } } } diff --git a/reference-apps/eshop/iac/environments/containers.bicep b/reference-apps/eshop/iac/environments/containers.bicep index 3ec52b08..a7703bab 100644 --- a/reference-apps/eshop/iac/environments/containers.bicep +++ b/reference-apps/eshop/iac/environments/containers.bicep @@ -12,19 +12,19 @@ resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepr 'Applications.Link/sqlDatabases': { sqldatabase: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/sqldatabases:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/sqldatabases:edge' } } 'Applications.Link/redisCaches': { rediscache: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rediscaches:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rediscaches:edge' } } - 'Applications.Link/extenders': { + 'Applications.Link/rabbitMQMessageQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'willsmithradius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index 090496d3..ae380684 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -8,7 +8,7 @@ param appName string = 'eshop' @description('Radius environment ID. Set automatically by Radius') param environment string -@description('SQL administrator username. Defaults to "SA"') +@description('SQL administrator username') param adminLogin string = 'SA' @description('SQL administrator password') diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index fb77afef..87df524b 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -7,13 +7,14 @@ param environment string param application string @description('SQL administrator username') +@secure() param adminLogin string @description('SQL administrator password') @secure() param adminPassword string -@description('Use Azure Service Bus for messaging. Defaults to "False"') +@description('Use Azure Service Bus for messaging. Allowed values: "True", "False".') @allowed([ 'True' 'False' @@ -108,7 +109,7 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = } } -resource rabbitmq 'Applications.Link/extenders@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'False') { +resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'False') { name: 'rabbitmq' properties: { application: application @@ -161,4 +162,4 @@ output rabbitmq string = rabbitmq.name output servicebus string = servicebus.name @description('Event Bus connection string') -output eventbusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.secrets('connectionString') : rabbitmq.secrets('connectionString') +output eventbusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.secrets('connectionString') : rabbitmq.properties.host From d2dd5c2d28172b2f3976cf196f66926bf5571a34 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 15 Aug 2023 12:02:55 -0700 Subject: [PATCH 10/12] PR Comments --- reference-apps/eshop/iac/eshop.bicep | 12 ++++++------ reference-apps/eshop/iac/infra/infra.bicep | 2 +- reference-apps/eshop/iac/services/basket.bicep | 4 ++-- reference-apps/eshop/iac/services/catalog.bicep | 4 ++-- reference-apps/eshop/iac/services/ordering.bicep | 8 ++++---- reference-apps/eshop/iac/services/payment.bicep | 4 ++-- reference-apps/eshop/iac/services/webhooks.bicep | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/reference-apps/eshop/iac/eshop.bicep b/reference-apps/eshop/iac/eshop.bicep index ae380684..ca171bfd 100644 --- a/reference-apps/eshop/iac/eshop.bicep +++ b/reference-apps/eshop/iac/eshop.bicep @@ -15,7 +15,7 @@ param adminLogin string = 'SA' @secure() param adminPassword string = newGuid() -@description('Container orchestrator to use. Defaults to "K8S') +@description('Container orchestrator to use. Defaults to "K8S"') @allowed([ 'K8S' ]) @@ -94,7 +94,7 @@ module basket 'services/basket.bicep' = { basketGrpcName: networking.outputs.basketGrpc redisBasketName: infra.outputs.redisBasket TAG: TAG - eventbusConnectionString: infra.outputs.eventbusConnectionString + eventBusConnectionString: infra.outputs.eventBusConnectionString } } @@ -111,7 +111,7 @@ module catalog 'services/catalog.bicep' = { ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE sqlCatalogDbName: infra.outputs.sqlCatalogDb TAG: TAG - eventbusConnectionString: infra.outputs.eventbusConnectionString + eventBusConnectionString: infra.outputs.eventBusConnectionString } } @@ -153,7 +153,7 @@ module ordering 'services/ordering.bicep' = { redisKeystoreName: infra.outputs.redisKeystore sqlOrderingDbName: infra.outputs.sqlOrderingDb TAG: TAG - eventbusConnectionString: infra.outputs.eventbusConnectionString + eventBusConnectionString: infra.outputs.eventBusConnectionString } } @@ -166,7 +166,7 @@ module payment 'services/payment.bicep' = { ORCHESTRATOR_TYPE: ORCHESTRATOR_TYPE paymentHttpName: networking.outputs.paymentHttp TAG: TAG - eventbusConnectionString: infra.outputs.eventbusConnectionString + eventBusConnectionString: infra.outputs.eventBusConnectionString } } @@ -208,7 +208,7 @@ module webhooks 'services/webhooks.bicep' = { TAG: TAG webhooksclientHttpName: networking.outputs.webhooksclientHttp webhooksHttpName: networking.outputs.webhooksHttp - eventbusConnectionString: infra.outputs.eventbusConnectionString + eventBusConnectionString: infra.outputs.eventBusConnectionString } } diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index 87df524b..07f0b8f9 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -162,4 +162,4 @@ output rabbitmq string = rabbitmq.name output servicebus string = servicebus.name @description('Event Bus connection string') -output eventbusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.secrets('connectionString') : rabbitmq.properties.host +output eventBusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.secrets('connectionString') : rabbitmq.properties.host diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index b380da60..480587d6 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -41,7 +41,7 @@ param redisBasketName string @description('The connection string for the event bus') @secure() -param eventbusConnectionString string +param eventBusConnectionString string // Container ------------------------------------- @@ -63,7 +63,7 @@ resource basket 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: redisBasket.connectionString() - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index f2277152..18adad8d 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -45,7 +45,7 @@ param sqlCatalogDbName string @description('The connection string for the event bus') @secure() -param eventbusConnectionString string +param eventBusConnectionString string // VARIABLES ----------------------------------------------------------------------------------- @@ -72,7 +72,7 @@ resource catalog 'Applications.Core/containers@2022-03-15-privatepreview' = { ApplicationInsights__InstrumentationKey: APPLICATION_INSIGHTS_KEY AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlCatalogDb.connectionString() - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString } ports: { http: { diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index 7642e948..e64fe45b 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -56,7 +56,7 @@ param sqlOrderingDbName string @description('The connection string for the event bus') @secure() -param eventbusConnectionString string +param eventBusConnectionString string // CONTAINERS ------------------------------------------------------- @@ -82,7 +82,7 @@ resource ordering 'Applications.Core/containers@2022-03-15-privatepreview' = { GRPC_PORT: '81' PORT: '80' ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } @@ -129,7 +129,7 @@ resource orderbgtasks 'Applications.Core/containers@2022-03-15-privatepreview' = OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlOrderingDb.connectionString() - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString } ports: { http: { @@ -162,7 +162,7 @@ resource orderingsignalrhub 'Applications.Core/containers@2022-03-15-privateprev OrchestratorType: ORCHESTRATOR_TYPE IsClusterEnv: 'True' AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString SignalrStoreConnectionString: redisKeystore.connectionString() identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' diff --git a/reference-apps/eshop/iac/services/payment.bicep b/reference-apps/eshop/iac/services/payment.bicep index 0cec4542..2bbaa9d2 100644 --- a/reference-apps/eshop/iac/services/payment.bicep +++ b/reference-apps/eshop/iac/services/payment.bicep @@ -29,7 +29,7 @@ param paymentHttpName string @description('The connection string for the event bus') @secure() -param eventbusConnectionString string +param eventBusConnectionString string // CONTAINERS --------------------------------------------------------- @@ -46,7 +46,7 @@ resource payment 'Applications.Core/containers@2022-03-15-privatepreview' = { 'Serilog__MinimumLevel__Override__Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ': 'Verbose' OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString } ports: { http: { diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 8ab5017a..743448d3 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -38,7 +38,7 @@ param sqlWebhooksDbName string @description('The connection string for the event bus') @secure() -param eventbusConnectionString string +param eventBusConnectionString string // CONTAINERS ----------------------------------------------------------- @@ -56,7 +56,7 @@ resource webhooks 'Applications.Core/containers@2022-03-15-privatepreview' = { OrchestratorType: ORCHESTRATOR_TYPE AzureServiceBusEnabled: AZURESERVICEBUSENABLED ConnectionString: sqlWebhooksDb.connectionString() - EventBusConnection: eventbusConnectionString + EventBusConnection: eventBusConnectionString identityUrl: identityHttp.properties.url IdentityUrlExternal: '${gateway.properties.url}/${identityHttp.properties.hostname}' } From a34d29ea4591559d843989e27058835ff95c1311 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 12 Sep 2023 10:42:40 -0700 Subject: [PATCH 11/12] Updating eshop defs --- .../eshop/iac/environments/aws.bicep | 8 ++++---- .../eshop/iac/environments/azure.bicep | 6 +++--- .../eshop/iac/environments/containers.bicep | 8 ++++---- reference-apps/eshop/iac/infra/infra.bicep | 18 +++++++++--------- reference-apps/eshop/iac/services/basket.bicep | 2 +- .../eshop/iac/services/catalog.bicep | 2 +- .../eshop/iac/services/identity.bicep | 4 ++-- .../eshop/iac/services/ordering.bicep | 4 ++-- .../eshop/iac/services/webhooks.bicep | 2 +- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/reference-apps/eshop/iac/environments/aws.bicep b/reference-apps/eshop/iac/environments/aws.bicep index 7dc4e532..c38d6a90 100644 --- a/reference-apps/eshop/iac/environments/aws.bicep +++ b/reference-apps/eshop/iac/environments/aws.bicep @@ -23,7 +23,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } } recipes: { - 'Applications.Link/sqlDatabases': { + 'Applications.Datastores/sqlDatabases': { sqldatabase: { templateKind: 'bicep' templatePath: 'radiusdev.azurecr.io/recipes/aws/sqldatabases:pr-29' @@ -32,7 +32,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } } } - 'Applications.Link/redisCaches': { + 'Applications.Datastores/redisCaches': { rediscache: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/aws/rediscaches:edge' @@ -42,10 +42,10 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' } } // Temporarily using containerized rabbitmq until we can use SQS or AmazonMQ - 'Applications.Link/rabbitMQMessageQueues': { + 'Applications.Messaging/rabbitMQQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqqueues:edge' } } } diff --git a/reference-apps/eshop/iac/environments/azure.bicep b/reference-apps/eshop/iac/environments/azure.bicep index b0525398..5708f5a5 100644 --- a/reference-apps/eshop/iac/environments/azure.bicep +++ b/reference-apps/eshop/iac/environments/azure.bicep @@ -20,19 +20,19 @@ resource azureEShopEnv 'Applications.Core/environments@2022-03-15-privatepreview } } recipes: { - 'Applications.Link/sqlDatabases': { + 'Applications.Datastores/sqlDatabases': { sqldatabase: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/azure/sqldatabases:latest' } } - 'Applications.Link/redisCaches': { + 'Applications.Datastores/redisCaches': { rediscache: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/azure/rediscaches:latest' } } - 'Applications.Link/extenders': { + 'Applications.Core/extenders': { servicebus: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/azure/extender-servicebus:latest' diff --git a/reference-apps/eshop/iac/environments/containers.bicep b/reference-apps/eshop/iac/environments/containers.bicep index a7703bab..cc3086fc 100644 --- a/reference-apps/eshop/iac/environments/containers.bicep +++ b/reference-apps/eshop/iac/environments/containers.bicep @@ -9,22 +9,22 @@ resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepr namespace: 'containers-eshop' } recipes: { - 'Applications.Link/sqlDatabases': { + 'Applications.Datastores/sqlDatabases': { sqldatabase: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/local-dev/sqldatabases:edge' } } - 'Applications.Link/redisCaches': { + 'Applications.Datastores/redisCaches': { rediscache: { templateKind: 'bicep' templatePath: 'radius.azurecr.io/recipes/local-dev/rediscaches:edge' } } - 'Applications.Link/rabbitMQMessageQueues': { + 'Applications.Messaging/rabbitMQQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqqueues:edge' } } } diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index 07f0b8f9..013b421e 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -23,7 +23,7 @@ param AZURESERVICEBUSENABLED string // Links --------------------------------------------------------------- -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { +resource sqlIdentityDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' = { name: 'identitydb' properties: { application: application @@ -39,7 +39,7 @@ resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview } } -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { +resource sqlCatalogDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' = { name: 'catalogdb' properties: { application: application @@ -55,7 +55,7 @@ resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' } } -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { +resource sqlOrderingDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' = { name: 'orderingdb' properties: { application: application @@ -71,7 +71,7 @@ resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview } } -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' = { +resource sqlWebhooksDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' = { name: 'webhooksdb' properties: { application: application @@ -87,7 +87,7 @@ resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview } } -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { +resource redisKeystore 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' = { name: 'keystore-data' properties: { application: application @@ -98,7 +98,7 @@ resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' } } -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = { +resource redisBasket 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' = { name: 'basket-data' properties: { application: application @@ -109,18 +109,18 @@ resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' = } } -resource rabbitmq 'Applications.Link/rabbitMQMessageQueues@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'False') { +resource rabbitmq 'Applications.Messaging/rabbitMQQueues@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'False') { name: 'rabbitmq' properties: { application: application environment: environment recipe: { - name: 'rabbitmqmessagequeue' + name: 'rabbitmqqueue' } } } -resource servicebus 'Applications.Link/extenders@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'True') { +resource servicebus 'Applications.Core/extenders@2022-03-15-privatepreview' = if (AZURESERVICEBUSENABLED == 'True') { name: 'servicebus' properties: { application: application diff --git a/reference-apps/eshop/iac/services/basket.bicep b/reference-apps/eshop/iac/services/basket.bicep index 480587d6..ad1b4cc0 100644 --- a/reference-apps/eshop/iac/services/basket.bicep +++ b/reference-apps/eshop/iac/services/basket.bicep @@ -111,6 +111,6 @@ resource basketGrpc 'Applications.Core/httpRoutes@2022-03-15-privatepreview' exi // Links ------------------------------------------ -resource redisBasket 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { +resource redisBasket 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' existing = { name: redisBasketName } diff --git a/reference-apps/eshop/iac/services/catalog.bicep b/reference-apps/eshop/iac/services/catalog.bicep index 18adad8d..a4d7a3ce 100644 --- a/reference-apps/eshop/iac/services/catalog.bicep +++ b/reference-apps/eshop/iac/services/catalog.bicep @@ -109,6 +109,6 @@ resource catalogGrpc 'Applications.Core/httpRoutes@2022-03-15-privatepreview' ex // LINKS ----------------------------------------------------------- -resource sqlCatalogDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { +resource sqlCatalogDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlCatalogDbName } diff --git a/reference-apps/eshop/iac/services/identity.bicep b/reference-apps/eshop/iac/services/identity.bicep index 484af5ab..81130344 100644 --- a/reference-apps/eshop/iac/services/identity.bicep +++ b/reference-apps/eshop/iac/services/identity.bicep @@ -156,10 +156,10 @@ resource webmvcHttp 'Applications.Core/httpRoutes@2022-03-15-privatepreview' exi // LINKS ----------------------------------------------------------- -resource sqlIdentityDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { +resource sqlIdentityDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlIdentityDbName } -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { +resource redisKeystore 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' existing = { name: redisKeystoreName } diff --git a/reference-apps/eshop/iac/services/ordering.bicep b/reference-apps/eshop/iac/services/ordering.bicep index e64fe45b..b78f9343 100644 --- a/reference-apps/eshop/iac/services/ordering.bicep +++ b/reference-apps/eshop/iac/services/ordering.bicep @@ -235,10 +235,10 @@ resource orderbgtasksHttp 'Applications.Core/httpRoutes@2022-03-15-privateprevie // LINKS ----------------------------------------------------------- -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { +resource redisKeystore 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' existing = { name: redisKeystoreName } -resource sqlOrderingDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { +resource sqlOrderingDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlOrderingDbName } diff --git a/reference-apps/eshop/iac/services/webhooks.bicep b/reference-apps/eshop/iac/services/webhooks.bicep index 743448d3..bfe4d0b2 100644 --- a/reference-apps/eshop/iac/services/webhooks.bicep +++ b/reference-apps/eshop/iac/services/webhooks.bicep @@ -136,6 +136,6 @@ resource webhooksclientHttp 'Applications.Core/httpRoutes@2022-03-15-privateprev // LINKS ----------------------------------------------------------- -resource sqlWebhooksDb 'Applications.Link/sqlDatabases@2022-03-15-privatepreview' existing = { +resource sqlWebhooksDb 'Applications.Datastores/sqlDatabases@2022-03-15-privatepreview' existing = { name: sqlWebhooksDbName } From ac8a0aebf6c9245290fb1951f1d5dc5ebb180451 Mon Sep 17 00:00:00 2001 From: willdavsmith Date: Tue, 12 Sep 2023 10:57:33 -0700 Subject: [PATCH 12/12] Fixing recipes --- reference-apps/eshop/iac/environments/aws.bicep | 2 +- reference-apps/eshop/iac/environments/containers.bicep | 2 +- reference-apps/eshop/iac/infra/infra.bicep | 2 +- reference-apps/eshop/iac/services/web.bicep | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reference-apps/eshop/iac/environments/aws.bicep b/reference-apps/eshop/iac/environments/aws.bicep index c38d6a90..4022cc9f 100644 --- a/reference-apps/eshop/iac/environments/aws.bicep +++ b/reference-apps/eshop/iac/environments/aws.bicep @@ -45,7 +45,7 @@ resource awsEshopEnv 'Applications.Core/environments@2022-03-15-privatepreview' 'Applications.Messaging/rabbitMQQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqqueues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/environments/containers.bicep b/reference-apps/eshop/iac/environments/containers.bicep index cc3086fc..6fd47e85 100644 --- a/reference-apps/eshop/iac/environments/containers.bicep +++ b/reference-apps/eshop/iac/environments/containers.bicep @@ -24,7 +24,7 @@ resource containersEShopEnv 'Applications.Core/environments@2022-03-15-privatepr 'Applications.Messaging/rabbitMQQueues': { rabbitmqmessagequeue: { templateKind: 'bicep' - templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqqueues:edge' + templatePath: 'radius.azurecr.io/recipes/local-dev/rabbitmqmessagequeues:edge' } } } diff --git a/reference-apps/eshop/iac/infra/infra.bicep b/reference-apps/eshop/iac/infra/infra.bicep index 013b421e..9cd58018 100644 --- a/reference-apps/eshop/iac/infra/infra.bicep +++ b/reference-apps/eshop/iac/infra/infra.bicep @@ -115,7 +115,7 @@ resource rabbitmq 'Applications.Messaging/rabbitMQQueues@2022-03-15-privateprevi application: application environment: environment recipe: { - name: 'rabbitmqqueue' + name: 'rabbitmqmessagequeue' } } } diff --git a/reference-apps/eshop/iac/services/web.bicep b/reference-apps/eshop/iac/services/web.bicep index 5de919f6..6d466b62 100644 --- a/reference-apps/eshop/iac/services/web.bicep +++ b/reference-apps/eshop/iac/services/web.bicep @@ -185,6 +185,6 @@ resource webshoppingapigwHttp 'Applications.Core/httpRoutes@2022-03-15-privatepr // LINKS ------------------------------------------------------ -resource redisKeystore 'Applications.Link/redisCaches@2022-03-15-privatepreview' existing = { +resource redisKeystore 'Applications.Datastores/redisCaches@2022-03-15-privatepreview' existing = { name: redisKeystoreName }