在 Azure Spring Cloud 中使用永久性存储Use persistent storage in Azure Spring Cloud

Azure Spring Cloud 为应用程序提供两种类型的存储:持久性和临时性。Azure Spring Cloud provides two types of storage for your application: persistent and temporary.

默认情况下,Azure Spring Cloud 为每个应用程序实例提供临时存储。By default, Azure Spring Cloud provides temporary storage for each application instance. 每个实例的临时存储有 5 GB 的容量限制,其默认安装路径为 /tmp。Temporary storage is limited to 5 GB per instance with the default mount path /tmp.

警告

重启应用程序实例会永久删除其关联的临时存储。If you restart an application instance, the associated temporary storage is permanently deleted.

持久存储是由 Azure 托管的文件共享容器,按应用程序分配。Persistent storage is a file-share container managed by Azure and allocated per application. 存储在持久存储中的数据由应用程序的所有实例共享。Data stored in persistent storage is shared by all instances of an application. 一个 Azure Spring Cloud 实例最多有 10 个启用了持久存储的应用程序。An Azure Spring Cloud instance can have a maximum of 10 applications with persistent storage enabled. 为每个应用程序分配 50 GB 的持久存储。Each application is allocated 50 GB of persistent storage. 持久存储的默认装载路径为 /persistent。The default mount path for persistent storage is /persistent.

警告

如果禁用应用程序的持久存储,则所有存储都将解除分配,并且存储的所有数据都将丢失。If you disable an applications's persistent storage, all of that storage is deallocated and all of the stored data is lost.

使用 Azure 门户启用持久存储Use the Azure portal to enable persistent storage

  1. 在 Azure 门户的“主页”页上,选择“所有资源” 。From the Home page of your Azure portal, select All Resources.

    找到“所有资源”图标

  2. 选择需要持久存储的 Azure Spring Cloud 资源。Select the Azure Spring Cloud resource that needs persistent storage. 在此示例中,所选应用程序名为 upspring。In this example, the selected application is called upspring.

    选择应用程序

  3. 在“设置”标题下,选择“应用” 。Under the Settings heading, select Apps.

  4. Azure Spring Cloud 服务随即显示在表中。Your Azure Spring Cloud services appear in a table. 选择要向其添加持久存储的服务。Select the service to which you want to add persistent storage. 本例选择了“网关”服务。In this example, the gateway service is selected.

    选择服务

  5. 在服务的配置页上选择“配置”From the service's configuration page, select Configuration

  6. 选择“持久存储”选项卡并选择“启用” 。Select the Persistent Storage tab and select Enable.

    启用持久存储

启用持久存储后,其大小和路径将显示在配置页上。After persistent storage is enabled, its size and path are shown on the configuration page.

使用 Azure CLI 修改持久存储Use the Azure CLI to modify persistent storage

如有必要,请安装用于 Azure CLI 的 Spring Cloud 扩展:If necessary, install the Spring Cloud extension for the Azure CLI:

az extension add --name spring-cloud

其他操作:Other operations:

  • 创建启用了持久存储的应用:To create an app with persistent storage enabled:

    az spring-cloud app create -n <app> -g <resource-group> -s <service-name> --enable-persistent-storage true
    
  • 为现有应用启用持久存储:To enable persistent storage for an existing app:

    az spring-cloud app update -n <app> -g <resource-group> -s <service-name> --enable-persistent-storage true
    
  • 在现有应用中禁用持久存储:To disable persistent storage in an existing app:

    az spring-cloud app update -n <app> -g <resource-group> -s <service-name> --enable-persistent-storage false
    

    警告

    如果禁用应用程序的持久存储,则所有存储都将解除分配,并且存储的所有数据都将永久丢失。If you disable an applications's persistent storage, all of that storage is deallocated and all of the stored data is permanently lost.

后续步骤Next steps