Quickstart: Provision Azure Spring Cloud using Azure CLI

This quickstart describes how to use Azure CLI to deploy an Azure Spring Cloud cluster into an existing virtual network.

Azure Spring Cloud makes it easy to deploy Spring Boot microservice applications to Azure without any code changes. The service manages the infrastructure of Spring Cloud applications so developers can focus on their code. Azure Spring Cloud provides lifecycle management using comprehensive monitoring and diagnostics, configuration management, service discovery, CI/CD integration, blue-green deployments, and more.

Prerequisites

  • An Azure subscription. If you don't have a subscription, create a free account before you begin.
  • Two dedicated subnets for the Azure Spring Cloud cluster, one for the service runtime and another for the Spring Boot micro-service applications. For subnet and virtual network requirements, see the Virtual network requirements section of Deploy Azure Spring Cloud in a virtual network.
  • An existing Log Analytics workspace for Azure Spring Cloud diagnostics settings and a workspace-based Application Insights resource. For more information, see Analyze logs and metrics with diagnostics settings and Application Insights Java In-Process Agent in Azure Spring Cloud.
  • Three internal Classless Inter-Domain Routing (CIDR) ranges (at least /16 each) that you've identified for use by the Azure Spring Cloud cluster. These CIDR ranges will not be directly routable and will be used only internally by the Azure Spring Cloud cluster. Clusters may not use 169.254.0.0/16, 172.30.0.0/16, 172.31.0.0/16, or 192.0.2.0/24 for the internal Spring Cloud CIDR ranges, or any IP ranges included within the cluster virtual network address range.
  • Service permission granted to the virtual network. The Azure Spring Cloud Resource Provider requires Owner permission to your virtual network in order to grant a dedicated and dynamic service principal on the virtual network for further deployment and maintenance. For instructions and more information, see the Grant service permission to the virtual network section of Deploy Azure Spring Cloud in a virtual network.
  • If you're using Azure Firewall or a Network Virtual Appliance (NVA), you'll also need to satisfy the following prerequisites:
  • Azure CLI

Review the Azure CLI deployment script

The deployment script used in this quickstart is from the Azure Spring Cloud reference architecture.

#!/bin/bash

echo "Enter Azure Subscription ID: "
read subscription
subscription=$subscription

echo "Enter Azure region for resource deployment: "
read region
location=$region

echo "Enter Azure Spring cloud Resource Group Name: "
read azurespringcloudrg
azurespringcloud_resource_group_name=$azurespringcloudrg

echo "Enter Azure Spring cloud VNet Resource Group Name: "
read azurespringcloudvnetrg
azurespringcloud_vnet_resource_group_name=$azurespringcloudvnetrg

echo "Enter Azure Spring cloud Spoke VNet : "
read azurespringcloudappspokevnet
azurespringcloudappspokevnet=$azurespringcloudappspokevnet

echo "Enter Azure Spring cloud App SubNet : "
read azurespringcloudappsubnet
azurespringcloud_app_subnet_name='/subscriptions/'$subscription'/resourcegroups/'$azurespringcloud_vnet_resource_group_name'/providers/Microsoft.Network/virtualNetworks/'$azurespringcloudappspokevnet'/subnets/'$azurespringcloudappsubnet

echo "Enter Azure Spring cloud Service SubNet : "
read azurespringcloudservicesubnet
azurespringcloud_service_subnet_name='/subscriptions/'$subscription'/resourcegroups/'$azurespringcloud_vnet_resource_group_name'/providers/Microsoft.Network/virtualNetworks/'$azurespringcloudappspokevnet'/subnets/'$azurespringcloudservicesubnet

echo "Enter Azure Log Analytics Workspace Resource Group Name: "
read loganalyticsrg
loganalyticsrg=$loganalyticsrg

echo "Enter Log Analytics Workspace Resource ID: "
read workspace
workspaceID='/subscriptions/'$subscription'/resourcegroups/'$loganalyticsrg'/providers/microsoft.operationalinsights/workspaces/'$workspace

echo "Enter Reserved CIDR Ranges for Azure Spring Cloud: "
read reservedcidrrange
reservedcidrrange=$reservedcidrrange

echo "Enter key=value pair used for tagging Azure Resources (space separated for multiple tags): "
read tag
tags=$tag

randomstring=$(LC_ALL=C tr -dc 'a-z0-9' < /dev/urandom | fold -w 13 | head -n 1)
azurespringcloud_service='spring-'$randomstring #Name of unique Spring Cloud resource
azurespringcloud_appinsights=$azurespringcloud_service
azurespringcloud_resourceid='/subscriptions/'$subscription'/resourceGroups/'$azurespringcloud_resource_group_name'/providers/Microsoft.AppPlatform/Spring/'$azurespringcloud_service

# Create Application Insights
az monitor app-insights component create \
    --app ${azurespringcloud_service} \
    --location ${location} \
    --kind web \
    -g ${azurespringcloudrg} \
    --application-type web \
    --workspace ${workspaceID}

# Create Azure Spring Cloud Instance
az spring-cloud create \
   -n ${azurespringcloud_service} \
   -g ${azurespringcloudrg} \
   -l ${location} \
   --enable-java-agent true \
   --app-insights ${azurespringcloud_service} \
   --sku Standard \
   --app-subnet ${azurespringcloud_app_subnet_name} \
   --service-runtime-subnet ${azurespringcloud_service_subnet_name} \
   --reserved-cidr-range ${reservedcidrrange} \
   --tags ${tags}

# Update diagnostic setting for Azure Spring Cloud instance
az monitor diagnostic-settings create  \
   --name monitoring \
   --resource ${azurespringcloud_resourceid} \
   --logs    '[{"category": "ApplicationConsole","enabled": true}]' \
   --workspace  ${workspaceID}

Deploy the cluster

To deploy the Azure Spring Cloud cluster using the Azure CLI script, follow these steps:

  1. Sign in to Azure by using the following command:

    az login
    

    After you sign in, this command will output information about all the subscriptions you have access to. Take note of the name and ID of the subscription you want to use.

  2. Set the target subscription.

    az account set --subscription "<your subscription name>"
    
  3. Register the Azure Spring Cloud Resource Provider.

    az provider register --namespace 'Microsoft.AppPlatform'
    
  4. Add the required extensions to Azure CLI.

    az extension add --name spring-cloud
    
  5. Choose a deployment location from the regions where Azure Spring Cloud is available, as shown in Products available by region.

  6. Use the following command to generate a list of Azure locations. Take note of the short Name value for the region you selected in the previous step.

    az account list-locations --output table
    
  7. Create a resource group to deploy the resource to.

    az group create --name <your-resource-group-name> --location <location-name>
    
  8. Save the deploySpringCloud.sh Bash script locally, then execute it from the Bash prompt.

    ./deploySpringCloud.sh
    
  9. Enter the following values when prompted by the script:

    • The Azure subscription ID that you saved earlier.
    • The Azure location name that you saved earlier.
    • The name of the resource group that you created earlier.
    • The name of the virtual network resource group where you'll deploy your resources.
    • The name of the spoke virtual network (for example, vnet-spoke).
    • The name of the subnet to be used by the Spring Cloud App Service (for example, snet-app).
    • The name of the subnet to be used by the Spring Cloud runtime service (for example, snet-runtime).
    • The name of the resource group for the Azure Log Analytics workspace to be used for storing diagnostic logs.
    • The name of the Azure Log Analytics workspace (for example, la-cb5sqq6574o2a).
    • The CIDR ranges from your virtual network to be used by Azure Spring Cloud (for example, XX.X.X.X/16,XX.X.X.X/16,XX.X.X.X/16).
    • The key/value pairs to be applied as tags on all resources that support tags. For more information, see Use tags to organize your Azure resources and management hierarchy. Use a space-separated list to apply multiple tags (for example, environment=Dev BusinessUnit=finance).

After you provide this information, the script will create and deploy the Azure resources.

Review deployed resources

You can either use the Azure portal to check the deployed resources, or use Azure CLI to list the deployed resources.

Clean up resources

If you plan to continue working with subsequent quickstarts and tutorials, you might want to leave these resources in place. When no longer needed, delete the resource group, which deletes the resources in the resource group. To delete the resource group by using Azure CLI, use the following commands:

echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."

Next steps

In this quickstart, you deployed an Azure Spring Cloud instance into an existing virtual network using Azure CLI, and then validated the deployment. To learn more about Azure Spring Cloud, continue on to the resources below.