快速入門:布建 Azure Spring Apps 標準取用和專用方案服務實例
本文內容
注意
Azure Spring Apps 是 Azure Spring Cloud 服務的新名稱。 雖然服務有新的名稱,但是您暫時還是會在某些位置看到舊的名稱。我們正在致力更新螢幕擷取畫面、影片和圖表等資產。
本文適用於: ✔️標準取用和專用 (預覽) ❌ 基本/標準 ❌ 企業
本文說明如何在 Azure Spring Apps 中建立標準取用和專用方案以進行應用程式部署。
必要條件
Azure 訂用帳戶。 如果您沒有訂用帳戶,請先建立免費帳戶 ,再開始操作。
(選擇性) Azure CLI 2.45.0 版或更高版本。 使用下列命令來安裝 Azure Spring Apps 擴充功能: az extension add --name spring
布建標準耗用量和專用方案實例
您可以使用 Azure 入口網站 或 Azure CLI 來建立標準取用和專用方案。
使用下列步驟,使用 Azure 入口網站 建立 Azure Spring Apps 的實例。
開啟 Azure 入口網站 。
在搜尋方塊中,搜尋 Azure Spring Apps,然後從結果中選取 [Azure Spring Apps ]。
在 [Azure Spring Apps] 頁面上,選取 [ 建立 ]。
使用下列指導方針填寫 Azure Spring Apps 建立 頁面上的基本概 念表單:
填寫 [建立容器應用程式環境] 頁面上的 [基本概 念] 窗體。 使用 [環境名稱] 的預設值asa-standard-consumption-app-env
,然後選擇 [方案] 的 [取用] 和 [專用] 工作負載配置檔 。
此時,您已建立具有默認標準取用工作負載配置檔的 Azure Container Apps 環境。 如果您想要將專用工作負載配置檔新增至相同的 Azure Container Apps 環境,您可以選取 [工作負載配置檔] 索引卷標,然後選取 [新增工作負載配置檔 ]。
選取 [檢閱和建立] 。
在 [Azure Spring Apps 建立] 頁面上,選取 [ 檢閱] 和 [建立] 以完成建立 Azure Spring Apps 實例。
注意
您也可以選擇使用自己的虛擬網路來建立 Azure Container Apps 環境。 如需詳細資訊,請參閱 快速入門:使用虛擬網路 在 Azure Container Apps 環境中建立 Azure Spring Apps 實例。
下列各節說明如何使用 Azure CLI 建立 Azure Spring Apps 的實例。
建立 Azure Container Apps 環境
Azure Container Apps 環境會在一組應用程式周圍建立安全界限。 部署至相同環境的應用程式會部署在相同的虛擬網路中,並將記錄寫入相同的Log Analytics工作區。
您可以使用下列兩種方式之一建立 Azure Container Apps 環境:
使用下列命令登入 Azure:
az login
使用下列命令來安裝適用於 Azure CLI 的 Azure Container Apps 擴充功能:
az extension add --name containerapp --upgrade
使用下列命令來註冊 Microsoft.App
命名空間:
az provider register --namespace Microsoft.App
如果您先前尚未使用 Azure 監視器 Log Analytics 工作區,請使用下列命令註冊 Microsoft.OperationalInsights
提供者:
az provider register --namespace Microsoft.OperationalInsights
使用下列命令來建立變數來儲存名稱和位置資訊。 請務必將佔位元值取代為您自己的值。
export RESOURCE_GROUP="<resource-group-name>"
export LOCATION="eastus"
export AZURE_CONTAINER_APPS_ENVIRONMENT="<Azure-Container-Apps-environment-name>"
使用下列命令來建立資源群組:
az group create \
--name $RESOURCE_GROUP \
--location $LOCATION
使用下列命令來建立 Azure Container Apps 環境:
az containerapp env create \
--resource-group $RESOURCE_GROUP \
--name $AZURE_CONTAINER_APPS_ENVIRONMENT \
--location $LOCATION \
--enable-workload-profiles
此時,您已建立具有默認標準取用工作負載配置檔的 Azure Container Apps 環境。 您也可以使用下列命令,將專用工作負載配置檔新增至相同的 Azure Container Apps 環境:
az containerapp env workload-profile set \
--resource-group $RESOURCE_GROUP \
--name $AZURE_CONTAINER_APPS_ENVIRONMENT \
--workload-profile-name my-wlp \
--workload-profile-type D4 \
--min-nodes 1 \
--max-nodes 2
部署 Azure Spring Apps 實例
使用下列步驟來部署服務實例:
使用下列命令來安裝適用於 Azure Spring Apps 的最新 Azure CLI 擴充功能:
az extension remove --name spring && \
az extension add --name spring
使用下列命令來註冊 Microsoft.AppPlatform
Azure Spring Apps 的提供者:
az provider register --namespace Microsoft.AppPlatform
使用下列命令來建立變數來儲存名稱和位置資訊。 如果您在上一節中設定變數,則可以略過前三個變數。 請務必將佔位元值取代為您自己的值。
export RESOURCE_GROUP="<resource-group-name>"
export LOCATION="eastus"
export AZURE_CONTAINER_APPS_ENVIRONMENT="<Azure-Container-Apps-environment-name>"
export AZURE_SPRING_APPS_INSTANCE="<Azure-Spring-Apps-instance-name>"
export MANAGED_ENV_RESOURCE_ID=$(az containerapp env show \
--resource-group $RESOURCE_GROUP \
--name $AZURE_CONTAINER_APPS_ENVIRONMENT \
--query id \
--output tsv)
使用下列命令,在容器環境之上部署 Azure Spring Apps 實例的標準耗用量和專用計劃。 指定您所建立的 Azure Container Apps 環境資源,以建立您的 Azure Spring Apps 實例。
az spring create \
--resource-group $RESOURCE_GROUP \
--name $AZURE_SPRING_APPS_INSTANCE \
--managed-environment $MANAGED_ENV_RESOURCE_ID \
--sku StandardGen2 \
--location $LOCATION
部署之後,系統會在訂用帳戶中建立基礎結構資源群組,以裝載 Azure Spring Apps Standard 耗用量和專用方案實例的基礎資源。 資源群組名為 {AZURE_CONTAINER_APPS_ENVIRONMENT}_SpringApps_{SPRING_APPS_SERVICE_ID}
,如下列命令所示:
export SERVICE_ID=$(az spring show \
--resource-group $RESOURCE_GROUP \
--name $AZURE_SPRING_APPS_INSTANCE \
--query properties.serviceId \
--output tsv)
export INFRA_RESOURCE_GROUP=${AZURE_CONTAINER_APPS_ENVIRONMENT}_SpringApps_${SERVICE_ID}
echo ${INFRA_RESOURCE_GROUP}
清除資源
當您不再需要資源時,請務必刪除您在本文中建立的資源。 若要刪除資源,只要刪除包含這些資源的資源群組即可。 您可以使用 Azure 入口網站 來刪除資源群組。 或者,若要使用 Azure CLI 刪除資源群組,請使用下列命令:
echo "Enter the Resource Group name:" &&
read resourceGroupName &&
az group delete --name $resourceGroupName &&
echo "Press [ENTER] to continue ..."
下一步