使用 Azure PowerShell 部署 Azure Spring CloudDeploy Azure Spring Cloud with Azure PowerShell

本文介绍如何使用 Az.SpringCloud PowerShell 模块创建 Azure Spring Cloud 实例。This article describes how you can create an instance of Azure Spring Cloud using the Az.SpringCloud PowerShell module.

要求Requirements

重要

尽管 Az.SpringCloud PowerShell 模块为预览版,但你需要使用 Install-Module cmdlet 单独安装它。While the Az.SpringCloud PowerShell module is in preview, you must install it separately using the Install-Module cmdlet. 此 PowerShell 模块正式发布后,它会包含在将来的 Az PowerShell 模块发行版中,并在 Azure Cloud Shell 中默认提供。After this PowerShell module becomes generally available, it will be part of future Az PowerShell module releases and available by default from within Azure Cloud Shell.

Install-Module -Name Az.SpringCloud
  • 如果有多个 Azure 订阅,请选择应当计费的资源所在的相应订阅。If you have multiple Azure subscriptions, choose the appropriate subscription in which the resources should be billed. 使用 Set-AzContext cmdlet 选择特定订阅。Select a specific subscription using the Set-AzContext cmdlet.

    Set-AzContext -SubscriptionId 00000000-0000-0000-0000-000000000000
    

创建资源组Create a resource group

使用 New-AzResourceGroup cmdlet 创建 Azure 资源组Create an Azure resource group using the New-AzResourceGroup cmdlet. 资源组是在其中以组的形式部署和管理 Azure 资源的逻辑容器。A resource group is a logical container in which Azure resources are deployed and managed as a group.

以下示例在指定位置创建具有指定名称的资源组。The following example creates a resource group with the specified name and in the specified location.

New-AzResourceGroup -Name <resource group name> -Location chinanorth

预配 Azure Spring Cloud 的新实例Provision a new instance of Azure Spring Cloud

若要创建 Azure Spring Cloud 的新实例,请使用 New-AzSpringCloud cmdlet。To create a new instance of Azure Spring Cloud, you use the New-AzSpringCloud cmdlet. 以下示例在先前创建的资源组中创建具有指定名称的 Azure Spring Cloud 服务。The following example creates an Azure Spring Cloud service with the specified name in the previously created resource group.

New-AzSpringCloud -ResourceGroupName <resource group name> -name <service instance name> -Location chinanorth

创建新的 Azure Spring Cloud 应用Create a new Azure Spring Cloud app

若要创建新应用,请使用 New-AzSpringCloudApp cmdlet。To create a new App, you use the New-AzSpringCloudApp cmdlet. 以下示例创建名为 gateway 的 Azure Spring Cloud 应用。The following example creates an Azure Spring Cloud app named gateway.

New-AzSpringCloudApp -ResourceGroupName <resource group name> -ServiceName <service instance name> -AppName gateway

创建新的 Azure Spring Cloud 部署Create a new Azure Spring Cloud deployment

若要创建新部署,请使用 New-AzSpringCloudAppDeployment cmdlet。To create a new Deployment, you use the New-AzSpringCloudAppDeployment cmdlet. 以下示例为 gateway 应用创建名为 default 的 Azure Spring Cloud 部署。The following example creates an Azure Spring Cloud deployment named default for the gateway app.

New-AzSpringCloudAppDeployment -ResourceGroupName <resource group name> -Name <service instance name> -AppName gateway -DeploymentName default

获取 Azure Spring Cloud 服务Get an Azure Spring Cloud service

若要获取 Azure Spring Cloud 服务及其属性,请使用 Get-AzSpringCloud cmdlet。To get an Azure Spring Cloud service and its properties, you use the Get-AzSpringCloud cmdlet. 以下示例检索有关指定的 Azure Spring Cloud 服务的信息。The following example retrieves information about the specified Azure Spring Cloud service.

Get-AzSpringCloud -ResourceGroupName <resource group name> -ServiceName <service instance name>

获取 Azure Spring Cloud 应用Get an Azure Spring Cloud app

若要获取 Azure Spring Cloud 应用及其属性,请使用 Get-AzSpringCloudApp cmdlet。To get an Azure Spring Cloud app and its properties, you use the Get-AzSpringCloudApp cmdlet. 以下示例检索有关 gateway Spring Cloud 应用的信息。The following example retrieves information about the gateway Spring Cloud app.

Get-AzSpringCloudApp -ResourceGroupName <resource group name> -ServiceName <service instance name> -AppName gateway

获取 Azure Spring Cloud 部署Get an Azure Spring Cloud deployment

若要获取 Azure Spring Cloud 部署及其属性,请使用 Get-AzSpringCloudAppDeployment cmdlet。To get an Azure Spring Cloud deployment and its properties, you use the Get-AzSpringCloudAppDeployment cmdlet. 以下示例检索有关 default Spring Cloud 部署的信息。The following example retrieves information about the default Spring Cloud deployment.

Get-AzSpringCloudAppDeployment -ResourceGroupName <resource group name> -ServiceName <service instance name> -AppName gateway -DeploymentName default

清理资源Clean up resources

如果不再需要使用本文中创建的资源,可以运行以下示例将其删除。If the resources created in this article aren't needed, you can delete them by running the following examples.

删除 Azure Spring Cloud 部署Delete an Azure Spring Cloud deployment

若要删除 Azure Spring Cloud 部署,请使用 Remove-AzSpringCloudAppDeployment cmdlet。To remove an Azure Spring Cloud deployment, you use the Remove-AzSpringCloudAppDeployment cmdlet. 以下示例为指定的服务和应用删除名为 default 的 Azure Spring Cloud 应用部署。The following example deletes an Azure Spring Cloud app deployment named default for the specified service and app.

Remove-AzSpringCloudAppDeployment -ResourceGroupName <resource group name> -ServiceName <service instance name> -AppName gateway -DeploymentName default

删除 Azure Spring Cloud 应用Delete an Azure Spring Cloud app

若要删除 Spring Cloud 应用,请使用 Remove-AzSpringCloudApp cmdlet。To remove a Spring Cloud app, you use the Remove-AzSpringCloudApp cmdlet. 以下示例删除指定服务和资源组中的 gateway 应用。The following example deletes the gateway app in the specified service and resource group.

Remove-AzSpringCloudApp -ResourceGroupName <resource group name> -ServiceName <service instance name> -AppName gateway

删除 Azure Spring Cloud 服务Delete an Azure Spring Cloud service

若要删除 Azure Spring Cloud 服务,请使用 Remove-AzSpringCloud cmdlet。To remove an Azure Spring Cloud service, you use the Remove-AzSpringCloud cmdlet. 以下示例删除指定的 Azure Spring Cloud 服务。The following example deletes the specified Azure Spring Cloud service.

Remove-AzSpringCloud -ResourceGroupName <resource group name> -ServiceName <service instance name>

删除资源组Delete the resource group

注意

以下示例删除指定的资源组及其包含的所有资源。The following example deletes the specified resource group and all resources contained within it. 如果指定的资源组中存在本文范围外的资源,这些资源也会被删除。If resources outside the scope of this article exist in the specified resource group, they will also be deleted.

Remove-AzResourceGroup -Name <resource group name>

后续步骤Next steps

Azure Spring Cloud 开发人员资源Azure Spring Cloud developer resources.