Export and import dynamic configurations

更新时间:
复制 MD 格式

Dynamic configuration lets you quickly export and import configurations. You can export configurations to create local backups and import configurations to quickly recover them. You can also export and import configurations between different environments.

Export dynamic configurations

  1. Log on to the SOFAStack console.

  2. In the left navigation pane, choose Middleware > Microservice Platform > Microservices > Dynamic Configuration.

  3. On the Dynamic Configuration page, choose More > Export.

    The dynamic configuration file is saved in JSON format to the default download folder of your browser.

Import dynamic configurations

  1. On the Dynamic Configuration page, choose More > Import.

  2. Click Browse, select the object file, and then click Open.

    You can import dynamic configuration files in JSON and TXT formats.

Dynamic configuration file format

Each line in the dynamic configuration file represents a complete JSON structure for a configuration class. A configuration class can contain multiple properties. The JSON-formatted data for multiple configuration classes is separated by line feeds. The format is as follows:

{
    "region":"Alipay",
    "appName":"testModel",
    "name":"Test Configuration",
    "resourceId":"com.alipay.test",
    "attributes":[
        {
            "attributeName":"age",
            "name":"Age"
        },
        {
            "attributeName":"name",
            "name":"Name"
        }
    ]
}

The parameters are described as follows:

Parameter

Description

region

The namespace of the configuration class.

appName

The name of the application to which the configuration class belongs.

resourceId

A string that represents the configuration class. This string must match the ID field of the @DObject annotation in the application code. The fully qualified class name is typically used.

name

The description of the configuration class.

attributes

The properties of the configuration class:

  • attributeName: The property name.

  • name: The property description.

Configuration file example:

[
    {
        "region":"Alipay",
        "appName":"testModel1",
        "name":"Configuration class description",
        "resourceId":"com.alipay.test",
        "attributes":[
            {
                "attributeName":"age",
                "name":"Property description"
            },
            {
                "attributeName":"name",
                "name":"Property description"
            }
        ]
    },
    {
        "region":"Alipay",
        "appName":"testModel2",
        "name":"Configuration class description",
        "resourceId":"com.alipay.test",
        "attributes":[
            {
                "attributeName":"age",
                "name":"Property description"
            },
            {
                "attributeName":"name",
                "name":"Property description"
            }
        ]
    }
]