https://github.com/carloslanderas/azure-app-configuration
Azure App Configuration Rust client
https://github.com/carloslanderas/azure-app-configuration
api-wrapper app-configuration azure cloud configuration keys keyvalues labels rust
Last synced: 5 months ago
JSON representation
Azure App Configuration Rust client
- Host: GitHub
- URL: https://github.com/carloslanderas/azure-app-configuration
- Owner: CarlosLanderas
- Created: 2019-09-09T14:19:01.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-16T08:49:52.000Z (over 2 years ago)
- Last Synced: 2025-05-08T00:13:44.740Z (5 months ago)
- Topics: api-wrapper, app-configuration, azure, cloud, configuration, keys, keyvalues, labels, rust
- Language: Rust
- Homepage:
- Size: 108 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Azure App Configuration client for Rust
[](https://travis-ci.org/CarlosLanderas/azure-app-configuration)
[](https://github.com/CarlosLanderas/azure-app-configuration)
[](https://crates.io/crates/azure-app-configuration)
[](https://docs.rs/azure-app-configuration)With **azure-app-configuration** you can easily work with your Azure App Configuration service centralized configurations.
Latest version supports:
- List keys
- List labels
- List key values
- Get key value
- Set key value (with label, tags and content type)
- Remove key value## Running samples
You can find some sample code snippets here: **[examples](https://github.com/CarlosLanderas/azure-app-configuration/tree/master/examples)**.
Just replace the configuration with your Azure configuration endpoint, your access_key and secret and execute them by using:
`cargo run --example list-key-values`
`cargo run --example get_key_value`
`cargo run --example set_key_value`
You can see all available targets in **[Cargo.toml](https://github.com/CarlosLanderas/azure-app-configuration/blob/master/Cargo.toml#L25-L42)** file
## Code samples
### Create an AzureAppConfiguration client
To create an Azure App Configuration client just use ::new method and provide the endpoint url, the access key and the secret:
```rust
use azure_app_configuration::client::AzureAppConfigClient;
let app_config_client = AzureAppConfigClient::new(
"https://endpoint.azconfig.io",
"0-l9-s0:Z6DMwn2DoiK2gVsTIm7h",
"wgf9BDWeh/+Dtq8Dmps3SUpwrdgYLrXG8svE+VyM06w=",
);
```### List keys
```rust
//List all key values without a label (all key values);
let keys = app_config_client.list_keys().await.unwrap();
for k in keys.items {
println!("{:?}", k);
}
```### List labels
```rust
let labels = app_config_client.list_labels().await.unwrap();
for l in labels.items {
println!("{:?}", l);
}
```### List Key Values
```rust
let key_values = app_config_client.list_key_values(SearchLabel::All).await;
for k in key_values {
println!("{:?}", k);
}
```### Get Key value with label
Retrieve value for key ConnectionString using label ContosoApp
```rust
let kv = app_config_client
.get_key_value("ConnectionString", SearchLabel::For("ContosoApp"))
.await;
println!("{:?}", kv);
```### Get Key value without label
Retrieve a label called ConnectionString with no label specified
```rust
let kv = app_config_client
.get_key_value("ConnectionString", SearchLabel::All)
.await;
println!("{:?}", kv);
```### Set key value
Delete ConnectionString key for Application1 label
```rust
let kv = app_config_client
.set_key(
"ConnectionString",
"Server=dummy;user id=user;password=fakepass",
SearchLabel::For("Application1"),
None,
None,
)
.await;println!("{:?}", kv);
```### Set key value with tags and content type
```rust
let mut tags = HashMap::new();
tags.insert("tag1", "tagvalue1");
tags.insert("tag2", "tagvalue2");let kv = app_config_client
.set_key(
"UseCache",
"true",
SearchLabel::For("PublicWebsite"),
Some(tags),
Some("application/lande"),
)
.await;println!("{:?}", kv);
```