|
2 | 2 | title: Import or export data with Azure App Configuration
|
3 | 3 | description: Learn how to import or export configuration data to or from Azure App Configuration. Exchange data between your App Configuration store and code project.
|
4 | 4 | services: azure-app-configuration
|
5 |
| -author: AlexandraKemperMS |
| 5 | +author: maud-lv |
6 | 6 | ms.service: azure-app-configuration
|
7 | 7 | ms.topic: conceptual
|
8 |
| -ms.date: 02/25/2020 |
9 |
| -ms.author: alkemper |
| 8 | +ms.date: 04/06/2022 |
| 9 | +ms.author: malev |
10 | 10 | ---
|
11 | 11 |
|
12 | 12 | # Import or export configuration data
|
13 | 13 |
|
14 |
| -Azure App Configuration supports data import and export operations. Use these operations to work with configuration data in bulk and exchange data between your App Configuration store and code project. For example, you can set up one App Configuration store for testing and another for production. You can copy application settings between them so that you don't have to enter data twice. |
| 14 | +Azure App Configuration supports data import and export operations. Use these operations to work with configuration data in bulk and exchange data between your App Configuration store and code project. For example, you can set up one App Configuration store for testing and another one for production. You can copy application settings between them so that you don't have to enter data twice. |
15 | 15 |
|
16 |
| -This article provides a guide for importing and exporting data with App Configuration. If you’d like to set up an ongoing sync with your GitHub repo, take a look at our [GitHub Action](./concept-github-action.md). |
| 16 | +This article provides a guide for importing and exporting data with App Configuration. If you’d like to set up an ongoing sync with your GitHub repo, take a look at [GitHub Actions](./concept-github-action.md) and [Azure Pipeline tasks](./pull-key-value-devops-pipeline.md). |
| 17 | + |
| 18 | +You can import or export data using either the [Azure portal](https://portal.azure.com) or the [Azure CLI](./scripts/cli-import.md). |
17 | 19 |
|
18 | 20 | ## Import data
|
19 | 21 |
|
20 |
| -Import brings configuration data into an App Configuration store from an existing source. Use the import function to migrate data into an App Configuration store or aggregate data from multiple sources. App Configuration supports importing from a JSON, YAML, or properties file. |
| 22 | +Import brings configuration data into an App Configuration store from an existing source. Use the import function to migrate data into an App Configuration store or aggregate data from multiple sources. App Configuration supports importing from another App Configuration store, an App Service resource or a configuration file in JSON, YAML or .properties. |
| 23 | + |
| 24 | +### [Portal](#tab/azure-portal) |
| 25 | + |
| 26 | +From the Azure portal, follow these steps: |
| 27 | + |
| 28 | +1. Browse to your App Configuration store, and select **Import/export** from the **Operations** menu. |
21 | 29 |
|
22 |
| -Import data by using either the [Azure portal](https://portal.azure.com) or the [Azure CLI](./scripts/cli-import.md). From the Azure portal, follow these steps: |
| 30 | + :::image type="content" source="./media/import-file.png" alt-text="Screenshot of the Azure portal, importing a file."::: |
23 | 31 |
|
24 |
| -1. Browse to your App Configuration store, and select **Import/Export** from the **Operations** menu. |
| 32 | +1. On the **Import** tab, select **Configuration file** under **Source service**. Other options are **App Configuration** and **App Services**. |
25 | 33 |
|
26 |
| -1. On the **Import** tab, select **Source service** > **Configuration File**. |
| 34 | +1. Fill out the form with the following parameters: |
27 | 35 |
|
28 |
| -1. Select **For language** and select your desired input type. |
| 36 | + | Parameter | Description | Examples | |
| 37 | + |--------------|------------------------------------------------------------------------------------------|---------| |
| 38 | + | For language | Choose the language of the file you're importing between .NET, Java (Spring) and Other. | .NET | |
| 39 | + | File type | Select the type of file you're importing between YAML, properties or JSON. | JSON | |
29 | 40 |
|
30 | 41 | 1. Select the **Folder** icon, and browse to the file to import.
|
31 | 42 |
|
32 |
| -  |
| 43 | +1. Fill out the next part of the form: |
| 44 | + |
| 45 | + | Parameter | Description | Example | |
| 46 | + |-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------| |
| 47 | + | Separator | The separator is the character parsed in your imported configuration file to separate key-values which will be added to your configuration store. Select one of the following options: `.`, `,`,`:`, `;`, `/`, `-`. | : | |
| 48 | + | Prefix | Optional. A key prefix is the beginning part of a key. Prefixes can be used to manage groups of keys in a configuration store. | TestApp:Settings:Backgroundcolor | |
| 49 | + | Label | Optional. Select an existing label or enter a new label that will be assigned to your imported key-values. | prod | |
| 50 | + | Content type | Optional. Indicate if the file you're importing is a Key Vault reference or a JSON file. For more information about Key Vault references, go to [Use Key Vault references in an ASP.NET Core app](/azure/azure-app-configuration/use-key-vault-references-dotnet-core). | JSON (application/json) | |
| 51 | + |
| 52 | +1. Select **Apply** to proceed with the import. |
| 53 | + |
| 54 | +### [Azure CLI](#tab/azure-cli) |
| 55 | + |
| 56 | +Use the Azure CLI as explained below to import App Configuration data. If you don't have the Azure CLI installed locally, you can optionally use [Azure Cloud Shell](/azure/cloud-shell/overview). Specify the source of the data: `appconfig`, `appservice` or `file`. Optionally specify a source label with `--src-label` and a label to apply with `--label`. |
33 | 57 |
|
34 |
| -1. Select a **Separator**, and optionally enter a **Prefix** to use for imported key names. |
| 58 | +Import all keys and feature flags from a file and apply test label. |
35 | 59 |
|
36 |
| -1. Optionally, select a **Label**. |
| 60 | +```azurecli |
| 61 | +az appconfig kv import --name <your-app-config-store-name> --label test --source file --path D:/abc.json --format json |
| 62 | +``` |
37 | 63 |
|
38 |
| -1. Select **Apply** to finish the import. |
| 64 | +Import all keys with label test and apply test2 label. |
39 | 65 |
|
40 |
| -  |
| 66 | +```azurecli |
| 67 | +az appconfig kv import --name <your-app-config-store-name> --source appconfig --src-label test --label test2 --src-name <another-app-config-store-name> |
| 68 | +``` |
| 69 | + |
| 70 | +Import all keys and apply null label from an App Service application. |
| 71 | + |
| 72 | +For `--appservice-account` use the ARM ID for AppService or use the name of the AppService, assuming it's in the same subscription and resource group as the App Configuration. |
| 73 | + |
| 74 | +```python |
| 75 | +az appconfig kv import --name <your-app-config-store-name> --source appservice --appservice-account <your-app-service> |
| 76 | +``` |
| 77 | + |
| 78 | +For more details and examples, go to [az appconfig kv import](/cli/azure/appconfig/kv?view=azure-cli-latest#az-appconfig-kv-import&preserve-view=true). |
| 79 | + |
| 80 | +--- |
41 | 81 |
|
42 | 82 | ## Export data
|
43 | 83 |
|
44 |
| -Export writes configuration data stored in App Configuration to another destination. Use the export function, for example, to save data in an App Configuration store to a file that's embedded with your application code during deployment. |
| 84 | +Export writes configuration data stored in App Configuration to another destination. Use the export function, for example, to save data from an App Configuration store to a file that can be embedded in your application code during deployment. You can export data from an App Configuration store, an App Service resource or a configuration file in JSON, YAML or .properties. |
| 85 | + |
| 86 | +### [Portal](#tab/azure-portal) |
45 | 87 |
|
46 |
| -Export data by using either the [Azure portal](https://portal.azure.com) or the [Azure CLI](./scripts/cli-export.md). From the Azure portal, follow these steps: |
| 88 | +From the [Azure portal](https://portal.azure.com), follow these steps: |
47 | 89 |
|
48 |
| -1. Browse to your App Configuration store, and select **Import/Export**. |
| 90 | +1. Browse to your App Configuration store, and select **Import/export**. |
49 | 91 |
|
50 |
| -1. On the **Export** tab, select **Target service** > **Configuration File**. |
| 92 | +1. On the **Export** tab, select **Target service** > **Configuration file**. |
51 | 93 |
|
52 |
| -1. Optionally enter a **Prefix** and select a **Label** and a point-in-time for keys to be exported. |
| 94 | +1. Fill out the form with the following parameters: |
53 | 95 |
|
54 |
| -1. Select a **File type** > **Separator**. |
| 96 | + | Parameter | Description | Example | |
| 97 | + |------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------| |
| 98 | + | Prefix | Optional. A key prefix is the beginning part of a key. Enter a prefix to restrict your export to key-values with the specified prefix. | TestApp:Settings:Backgroundcolor | |
| 99 | + | From label | Optional. Select an existing label to restrict your export to key-values with a specific label. If you don't select a label, only key-values without a label will be exported. See note below. | prod | |
| 100 | + | At a specific time | Optional. Fill out to export key-values from a specific point in time. | 01/28/2021 12:00:00 AM | |
| 101 | + | File type | Select the type of file you're importing between YAML, properties or JSON. | JSON | |
| 102 | + | Separator | The separator is the character that will be used in the configuration file to separate the exported key-values from one another. Select one of the following options: `.`, `,`,`:`, `;`, `/`, `-`. | ; | |
55 | 103 |
|
56 |
| -1. Select **Apply** to finish the export. |
| 104 | + > [!IMPORTANT] |
| 105 | + > If you don't select a label, only keys without labels will be exported. To export a key-value with a label, you must select its label. Note that you can only select one label per export, so to export keys with multiple labels, you may need to export multiple times, once per label you select. |
57 | 106 |
|
58 |
| -  |
| 107 | +1. Select **Export** to finish the export. |
| 108 | + |
| 109 | + :::image type="content" source="./media/export-file-complete.png" alt-text="Screenshot of the Azure portal, exporting a file"::: |
| 110 | + |
| 111 | +### [Azure CLI](#tab/azure-cli) |
| 112 | + |
| 113 | +Use the Azure CLI as explained below to export configurations from App Configuration to another place. If you don't have the Azure CLI installed locally, you can optionally use [Azure Cloud Shell](/azure/cloud-shell/overview). Specify the destination of the data: `appconfig`, `appservice` or `file`. Specify a label for the data you want to export with `--label` or export data with no label by not entering a label. |
| 114 | + |
| 115 | +> [!IMPORTANT] |
| 116 | +> If the keys you want to export have labels, do select the corresponding labels. If you don't select a label, only keys without labels will be exported. |
| 117 | +
|
| 118 | +Export all keys and feature flags with label test to a json file. |
| 119 | + |
| 120 | +```python |
| 121 | +az appconfig kv export --name <your-app-config-store-name> --label test --destination file --path D:/abc.json --format json |
| 122 | +``` |
| 123 | + |
| 124 | +Export all keys with null label excluding feature flags to a json file. |
| 125 | + |
| 126 | +```python |
| 127 | +az appconfig kv export --name <your-app-config-store-name> --destination file --path D:/abc.json --format json --skip-features |
| 128 | +``` |
| 129 | + |
| 130 | +Export all keys and feature flags with all labels to another App Configuration. |
| 131 | + |
| 132 | +```python |
| 133 | +az appconfig kv export --name <your-app-config-store-name> --destination appconfig --dest-name <another-app-config-store-name> --key * --label * --preserve-labels |
| 134 | +``` |
| 135 | + |
| 136 | +Export all keys and feature flags with all labels to another App Configuration and overwrite destination labels. |
| 137 | + |
| 138 | +```python |
| 139 | +az appconfig kv export --name <your-app-config-store-name> --destination appconfig --dest-name <another-app-config-store-name> --key * --label * --dest-label ExportedKeys |
| 140 | +``` |
| 141 | + |
| 142 | +For more details and examples, go to [az appconfig kv export](/cli/azure/appconfig/kv?view=azure-cli-latest#az-appconfig-kv-export&preserve-view=true). |
| 143 | + |
| 144 | +--- |
59 | 145 |
|
60 | 146 | ## Next steps
|
61 | 147 |
|
62 | 148 | > [!div class="nextstepaction"]
|
63 |
| -> [Create an ASP.NET Core web app](./quickstart-aspnet-core-app.md) |
| 149 | +> [Create an ASP.NET Core web app](./quickstart-aspnet-core-app.md) |
0 commit comments