You can test and configure the code-level design patterns introduced in this implementation: strangler fig, queue-based load leveling and competing consumers, and distributed tracing. The following paragraphs detail steps to test these code-level design patterns.
As an evolution of the Reliable Web App (RWA), the Modern Web App (MWA) reference sample also includes design patterns that were showcased in RWA: retry, circuit-breaker, and cache-aside. For more information on these patterns and how to test them (both in RWA and MWA), see Reliable Web App Pattern Simulations.
Read the Strangler Fig Pattern documentation.
After you deploy CAMS using azd up
, the application is configured to use the new email service. The default value for CONTOSO_SUPPORT_GUIDE_REQUEST_SERVICE
is set to queue
for the App Service. Email requests go to the Azure Service Bus and are processed by the email-processor
container app. This setting is defined in Azure App Configuration.
To simulate the functionality, follow the steps below:
-
Open the CAMS application in a browser.
-
Upload a support guide by clicking on the
Support Guides
link in the navigation bar and clickUpload New Guide
. The guides are located in thecontoso-guides
directory. -
Add an Account by clicking on the
Accounts
link in the navigation bar and clickAdd Account
. -
Click on the
New Support Case
button to create the Support Ticket. -
Click on the support case and and then click the
Email Customer
button. You will see log message in the support case that the email was sent. -
Navigate to the Container App in the Azure portal and click on the
Log Stream
link in the left navigation. -
Navigate to the Container App in the Azure portal and click on the
Log Stream
link in the left navigation.You will see the log messages from the
email-processor
container app andCAMS
.Note: It may take a few minutes for the message to be processed and the logs to appear.
-
Refresh the page and you will see that
CAMS
processed a response from theemail-processor
. -
Navigate to the Azure Service Bus in the Azure portal. You will see a spike in incoming messages.
To see messages go though the old email service, change the value of the CONTOSO_SUPPORT_GUIDE_REQUEST_SERVICE
key to email
in Azure App Configuration. This is simulated by issuing a log message when the email functionality is called.
You will also see a log message from the email service that the email was sent in the Azure portal.
You can also simulate the Strangler Fig Pattern and view the distributed tracing logs in Azure Monitor.
-
Navigate to the Azure Application Insights in the Azure portal and select the Transaction Search blade. Search for
New Message Received
to see the trace messages from theemail-processor
container app and theCAMS
application running on App Service. -
Click on the
New Message Received
transaction to see the details.
The email-processor
container app is configured to autoscale based on the number of messages in the Azure Service Bus. The email-processor
container app scales out when the number of messages in the Service Bus exceeds a certain threshold.
To simulate the autoscaling, follow the steps below:
-
Navigate to Azure App Configuration and change the
CONTOSO_SUPPORT_GUIDE_REQUEST_SERVICE
value todemo-load
. -
Restart the Web App in App Service.
-
Send an email following the steps in the Strangler Fig Pattern section.
-
Navigate to the Azure Service Bus in the Azure portal. You will see a spike in incoming messages.
-
Navigate to the Container App in the Azure portal and click on the
Revisions and replicas
link underApplication
in the left navigation. Finally, click on theReplicas
tab. You will see that the number of replicas has increased.