Exercise - Sample application environment
In this unit, we configure a sample Microservice architecture to be ready for autoscaling.
Note
You need access to an Azure subscription where you can create resources for this module. When you've finished the module, be sure to delete any resources you created to avoid charges to your subscription.
Set up the sample microservice application
In a web browser, open https://shell.azure.com in a new browser window.
Select Bash mode in the top right-hand side.
Next, in the bash window, run the following commands to clone the sample repository and open the built-in Azure editor:
git clone https://github.com/MicrosoftDocs/mslearn-autoscale-java cd mslearn-autoscale-java code deployPetClinicApp.sh
Set up and run the setup script
When you run the preceding command, a window pops up with the file deployPetClinicApp.sh
ready to be edited in the built-in Azure editor.
At the top of the
deployPetClinicApp.sh
file, edit the following variables to customize the scripts parameters for your environment. For all resource names, use lowercase letters - you can use hyphens and numbers also:Variable Description resource_group Provide a new or existing resource group name. region The Azure region. You can use westeurope
orcentralus
, but we recommend that you use a region close to where you live and that also supports Azure Spring Apps. To see the full list of available regions, visit the Azure Spring Apps Availability by Region in the Summary unit at the end of this module.spring_apps_service Name of your Azure Spring Apps instance. mysql_server_name The name of your MySQL server. It should be unique across Azure. mysql_server_admin_name Username for the MySQL Administrator. The admin name can't be azure-superuser, admin, administrator, root, guest, or public. mysql_server_admin_password A new password for the server admin user. The password must be 8 to 128 characters long and contain a combination of uppercase or lowercase letters, numbers, and nonalphanumeric characters (!, $, #, %, and so on). log_analytics Name of your Azure Log Analytics workspace Save the file by selecting the ... action panel in the top right of the editor and selecting Save. You can also use the Ctrl + S keys on Windows or Command + S on Mac.
Close the editor. Select the ... action panel in the top right of the editor and select Close Editor. You can also use the Ctrl + Q keys on Windows or Command + Q on Mac.
Don't close the Azure Cloud Shell, because we run the setup script next.
Run the setup script
The script takes 30-45 minutes to run and includes the creation of an Azure spring Apps and a MySQL instance. This sample script also sets up autoscale configuration for your microservices.
In the already open Azure Cloud Shell, run the following shell script. Leave the browser window and Azure Cloud Shell open while running. Store the URL when the script completes:
bash deployPetClinicApp.sh
Important
If you run into errors with the setup script, the script will attempt to delete any resources it creates. You can then try again once the resource group is fully deleted. The Summary unit has instructions on how do also delete your resources manually.
Test the application
Next, we verify your environment via the Azure portal.
Open the Azure portal.
Select Azure Spring Apps from the list of Azure services.
Select your Azure Spring Apps instance.
On the right-hand side, select Apps under Settings.
Verify all the applications are running and registered
On the left-hand side, select the api-gateway application.
The URL for your application is listed on the left-hand side properties as URL.
In a web browser, navigate to the URL of your api-gateway to open the Pet Clinic microservice application.
Next, navigate to the Owners tab and select Find all owners.
Confirm your sample application is up and running, populated with data, and ready for you to explore.