Skip to content

Commit

Permalink
[App Config] Snapshot API Updates Based on Arch Board Feedback (Azur…
Browse files Browse the repository at this point in the history
…e#38650)

 [App Configuration] Updates in snapshot API
  • Loading branch information
ShivangiReja authored and yaotongms committed Oct 12, 2023
1 parent eae7752 commit e47c95b
Show file tree
Hide file tree
Showing 17 changed files with 443 additions and 365 deletions.
26 changes: 13 additions & 13 deletions sdk/appconfiguration/Azure.Data.AppConfiguration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,26 @@ client.DeleteConfigurationSetting("some_key");

### Create a Snapshot

To create a snapshot, you need to instantiate the `ConfigurationSettingsSnapshot` class and specify filters to determine which configuration settings should be included. The creation process is a Long-Running Operation (LRO) and can be achieved by calling the `CreateSnapshot` method.
To create a snapshot, you need to instantiate the `ConfigurationSnapshot` class and specify filters to determine which configuration settings should be included. The creation process is a Long-Running Operation (LRO) and can be achieved by calling the `CreateSnapshot` method.

```C# Snippet:AzConfigSample11_CreateSnapshot_AutomaticPolling
var snapshotFilter = new List<SnapshotSettingFilter>(new SnapshotSettingFilter[] { new SnapshotSettingFilter("some_key") });
var settingsSnapshot = new ConfigurationSettingsSnapshot(snapshotFilter);
var snapshotFilter = new List<SnapshotSettingFilter> { new SnapshotSettingFilter("some_key") };
var settingsSnapshot = new ConfigurationSnapshot(snapshotFilter);

var snapshotName = "some_snapshot";
var operation = client.CreateSnapshot(WaitUntil.Completed, snapshotName, settingsSnapshot);
var createdSnapshot = operation.Value;
Console.WriteLine($"Created configuration setting snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");
Console.WriteLine($"Created configuration snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");
```

### Retrieve a Snapshot

Once a configuration setting snapshot is created, you can retrieve it using the `GetSnapshot` method.
Once a configuration snapshot is created, you can retrieve it using the `GetSnapshot` method.

```C# Snippet:AzConfigSample11_GetSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot retrievedSnapshot = client.GetSnapshot(snapshotName);
Console.WriteLine($"Retrieved configuration setting snapshot: {retrievedSnapshot.Name}, status: {retrievedSnapshot.Status}");
ConfigurationSnapshot retrievedSnapshot = client.GetSnapshot(snapshotName);
Console.WriteLine($"Retrieved configuration snapshot: {retrievedSnapshot.Name}, status: {retrievedSnapshot.Status}");
```

### Archive a Snapshot
Expand All @@ -188,8 +188,8 @@ To archive a snapshot, you can utilize the `ArchiveSnapshot` method. This operat

```C# Snippet:AzConfigSample11_ArchiveSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot archivedSnapshot = client.ArchiveSnapshot(snapshotName);
Console.WriteLine($"Archived configuration setting snapshot: {archivedSnapshot.Name}, status: {archivedSnapshot.Status}");
ConfigurationSnapshot archivedSnapshot = client.ArchiveSnapshot(snapshotName);
Console.WriteLine($"Archived configuration snapshot: {archivedSnapshot.Name}, status: {archivedSnapshot.Status}");
```

### Recover a snapshot
Expand All @@ -198,8 +198,8 @@ You can recover an archived snapshot by using the `RecoverSnapshot` method. This

```C# Snippet:AzConfigSample11_RecoverSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot recoveredSnapshot = client.RecoverSnapshot(snapshotName);
Console.WriteLine($"Recovered configuration setting snapshot: {recoveredSnapshot.Name}, status: {recoveredSnapshot.Status}");
ConfigurationSnapshot recoveredSnapshot = client.RecoverSnapshot(snapshotName);
Console.WriteLine($"Recovered configuration snapshot: {recoveredSnapshot.Name}, status: {recoveredSnapshot.Status}");
```

### Retrieve all Snapshots
Expand All @@ -208,10 +208,10 @@ To retrieve all snapshots, you can use the `GetSnapshots` method.

```C# Snippet:AzConfigSample11_GetSnapshots
var count = 0;
foreach (var item in client.GetSnapshots())
foreach (var item in client.GetSnapshots(new SnapshotSelector()))
{
count++;
Console.WriteLine($"Retrieved configuration setting snapshot: {item.Name}, status {item.Status}");
Console.WriteLine($"Retrieved configuration snapshot: {item.Name}, status {item.Status}");
}
Console.WriteLine($"Total number of snapshots retrieved: {count}");
```
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/appconfiguration/Azure.Data.AppConfiguration",
"Tag": "net/appconfiguration/Azure.Data.AppConfiguration_9577bdfe93"
"Tag": "net/appconfiguration/Azure.Data.AppConfiguration_c13e90b6f4"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@

Azure App Configuration allows users to create a point-in-time snapshot of their configuration store, providing them with the ability to treat settings as one consistent version. This feature enables applications to hold a consistent view of configuration, ensuring that there are no version mismatches to individual settings due to reading as updates were made. Snapshots are immutable, ensuring that configuration can confidently be rolled back to a last-known-good configuration in the event of a problem.

This sample illustrates how to create, retrieve, and modify the status of a `ConfigurationSettingSnapshot`.
This sample illustrates how to create, retrieve, and modify the status of a `ConfigurationSnapshot`.

To get started, you'll need to instantiate the `ConfigurationClient` class. In order to do so, you have two options: provide the connection string of the Configuration Store or authenticate with Azure Active Directory. For detailed instructions, please refer to the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/appconfiguration/Azure.Data.AppConfiguration/README.md#authenticate-the-client).

## Create a Snapshot

To create a snapshot, you need to create an instance of `ConfigurationSettingsSnapshot` and add filters to determine which configuration settings are included in the snapshot. The creation of a snapshot is an LRO (Long-Running Operation) method, and there are three ways to call the `CreateSnapshot` method:
To create a snapshot, you need to create an instance of `ConfigurationSnapshot` and add filters to determine which configuration settings are included in the snapshot. The creation of a snapshot is an LRO (Long-Running Operation) method, and there are three ways to call the `CreateSnapshot` method:

### Automatic Polling

```C# Snippet:AzConfigSample11_CreateSnapshot_AutomaticPolling
var snapshotFilter = new List<SnapshotSettingFilter>(new SnapshotSettingFilter[] { new SnapshotSettingFilter("some_key") });
var settingsSnapshot = new ConfigurationSettingsSnapshot(snapshotFilter);
var snapshotFilter = new List<SnapshotSettingFilter> { new SnapshotSettingFilter("some_key") };
var settingsSnapshot = new ConfigurationSnapshot(snapshotFilter);

var snapshotName = "some_snapshot";
var operation = client.CreateSnapshot(WaitUntil.Completed, snapshotName, settingsSnapshot);
var createdSnapshot = operation.Value;
Console.WriteLine($"Created configuration setting snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");
Console.WriteLine($"Created configuration snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");
```

### Automatic Polling with `WaitForCompletion`

```C# Snippet:AzConfigSample11_CreateSnapshot_AutomaticPollingLater
var snapshotFilter = new List<SnapshotSettingFilter>(new SnapshotSettingFilter[] { new SnapshotSettingFilter("some_key") });
var settingsSnapshot = new ConfigurationSettingsSnapshot(snapshotFilter);
var snapshotFilter = new List<SnapshotSettingFilter> { new SnapshotSettingFilter("some_key") };
var settingsSnapshot = new ConfigurationSnapshot(snapshotFilter);

var snapshotName = "some_snapshot";
var operation = client.CreateSnapshot(WaitUntil.Started, snapshotName, settingsSnapshot);
operation.WaitForCompletion();

var createdSnapshot = operation.Value;
Console.WriteLine($"Created configuration setting snapshot: {createdSnapshot.Name}, status: {createdSnapshot.Status}");
Console.WriteLine($"Created configuration snapshot: {createdSnapshot.Name}, status: {createdSnapshot.Status}");
```

### Manual Polling

```C# Snippet:AzConfigSample11_CreateSnapshot_ManualPolling
var snapshotFilter = new List<SnapshotSettingFilter>(new SnapshotSettingFilter[] { new SnapshotSettingFilter("some_key") });
var settingsSnapshot = new ConfigurationSettingsSnapshot(snapshotFilter);
var snapshotFilter = new List<SnapshotSettingFilter> { new SnapshotSettingFilter("some_key") };
var settingsSnapshot = new ConfigurationSnapshot(snapshotFilter);

var snapshotName = "some_snapshot";
var operation = client.CreateSnapshot(WaitUntil.Started, snapshotName, settingsSnapshot);
Expand All @@ -53,7 +53,7 @@ while (true)
}

var createdSnapshot = operation.Value;
Console.WriteLine($"Created configuration setting snapshot: {createdSnapshot.Name}, status: {createdSnapshot.Status}");
Console.WriteLine($"Created configuration snapshot: {createdSnapshot.Name}, status: {createdSnapshot.Status}");
```

## Retrieve a Snapshot
Expand All @@ -62,8 +62,8 @@ After creating a configuration setting snapshot, you can retrieve it using the `

```C# Snippet:AzConfigSample11_GetSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot retrievedSnapshot = client.GetSnapshot(snapshotName);
Console.WriteLine($"Retrieved configuration setting snapshot: {retrievedSnapshot.Name}, status: {retrievedSnapshot.Status}");
ConfigurationSnapshot retrievedSnapshot = client.GetSnapshot(snapshotName);
Console.WriteLine($"Retrieved configuration snapshot: {retrievedSnapshot.Name}, status: {retrievedSnapshot.Status}");
```

## Archive a Snapshot
Expand All @@ -72,8 +72,8 @@ To archive a snapshot, you can use the `ArchiveSnapshot` method. This operation

```C# Snippet:AzConfigSample11_ArchiveSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot archivedSnapshot = client.ArchiveSnapshot(snapshotName);
Console.WriteLine($"Archived configuration setting snapshot: {archivedSnapshot.Name}, status: {archivedSnapshot.Status}");
ConfigurationSnapshot archivedSnapshot = client.ArchiveSnapshot(snapshotName);
Console.WriteLine($"Archived configuration snapshot: {archivedSnapshot.Name}, status: {archivedSnapshot.Status}");
```

## Recover a snapshot
Expand All @@ -82,8 +82,8 @@ To recover an archived snapshot, you can use the `RecoverSnapshot` method. This

```C# Snippet:AzConfigSample11_RecoverSnapshot
var snapshotName = "some_snapshot";
ConfigurationSettingsSnapshot recoveredSnapshot = client.RecoverSnapshot(snapshotName);
Console.WriteLine($"Recovered configuration setting snapshot: {recoveredSnapshot.Name}, status: {recoveredSnapshot.Status}");
ConfigurationSnapshot recoveredSnapshot = client.RecoverSnapshot(snapshotName);
Console.WriteLine($"Recovered configuration snapshot: {recoveredSnapshot.Name}, status: {recoveredSnapshot.Status}");
```

## Retrieve all Snapshots
Expand All @@ -92,10 +92,10 @@ To retrieve all snapshots, you can use the `GetSnapshots` method.

```C# Snippet:AzConfigSample11_GetSnapshots
var count = 0;
foreach (var item in client.GetSnapshots())
foreach (var item in client.GetSnapshots(new SnapshotSelector()))
{
count++;
Console.WriteLine($"Retrieved configuration setting snapshot: {item.Name}, status {item.Status}");
Console.WriteLine($"Retrieved configuration snapshot: {item.Name}, status {item.Status}");
}
Console.WriteLine($"Total number of snapshots retrieved: {count}");
```
Expand All @@ -111,13 +111,13 @@ client.AddConfigurationSetting(firstSetting);
var secondSetting = new ConfigurationSetting("second_key", "second_value");
client.AddConfigurationSetting(secondSetting);

var snapshotFilter = new List<SnapshotSettingFilter>(new SnapshotSettingFilter[] { new SnapshotSettingFilter(firstSetting.Key), new SnapshotSettingFilter(secondSetting.Key) });
var settingsSnapshot = new ConfigurationSettingsSnapshot(snapshotFilter);
var snapshotFilter = new List<SnapshotSettingFilter> { new SnapshotSettingFilter(firstSetting.Key), new SnapshotSettingFilter(secondSetting.Key) };
var settingsSnapshot = new ConfigurationSnapshot(snapshotFilter);

var snapshotName = "some_snapshot";
var operation = client.CreateSnapshot(WaitUntil.Completed, snapshotName, settingsSnapshot);
var createdSnapshot = operation.Value;
Console.WriteLine($"Created configuration setting snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");
Console.WriteLine($"Created configuration snapshot: {createdSnapshot.Name}, Status: {createdSnapshot.Status}");

var count = 0;
foreach (var item in client.GetConfigurationSettingsForSnapshot(snapshotName))
Expand Down
Loading

0 comments on commit e47c95b

Please sign in to comment.