diff --git a/daprdocs/content/en/concepts/building-blocks-concept.md b/daprdocs/content/en/concepts/building-blocks-concept.md index 0bdeaed19b5..1346b7bfcce 100644 --- a/daprdocs/content/en/concepts/building-blocks-concept.md +++ b/daprdocs/content/en/concepts/building-blocks-concept.md @@ -27,6 +27,6 @@ The following are the building blocks provided by Dapr: | [**Actors**]({{< ref "actors-overview.md" >}}) | `/v1.0/actors` | An actor is an isolated, independent unit of compute and state with single-threaded execution. Dapr provides an actor implementation based on the virtual actor pattern which provides a single-threaded programming model and where actors are garbage collected when not in use. | [**Observability**]({{< ref "observability-concept.md" >}}) | `N/A` | Dapr system components and runtime emit metrics, logs, and traces to debug, operate and monitor Dapr system services, components and user applications. | [**Secrets**]({{< ref "secrets-overview.md" >}}) | `/v1.0/secrets` | Dapr provides a secrets building block API and integrates with secret stores such as public cloud stores, local stores and Kubernetes to store the secrets. Services can call the secrets API to retrieve secrets, for example to get a connection string to a database. -| [**Configuration**]({{< ref "configuration-api-overview.md" >}}) | `/v1.0-alpha1/configuration` | The Configuration API enables you to retrieve and subscribe to application configuration items for supported configuration stores. This enables an application to retrieve specific configuration information, for example, at start up or when configuration changes are made in the store. +| [**Configuration**]({{< ref "configuration-api-overview.md" >}}) | `/v1.0/configuration` | The Configuration API enables you to retrieve and subscribe to application configuration items for supported configuration stores. This enables an application to retrieve specific configuration information, for example, at start up or when configuration changes are made in the store. | [**Distributed lock**]({{< ref "distributed-lock-api-overview.md" >}}) | `/v1.0-alpha1/lock` | The distributed lock API enables you to take a lock on a resource so that multiple instances of an application can access the resource without conflicts and provide consistency guarantees. | [**Workflows**]({{< ref "workflow-overview.md" >}}) | `/v1.0-alpha1/workflow` | The Workflow API enables you to define long running, persistent processes or data flows that span multiple microservices using Dapr workflows or workflow components. The Workflow API can be combined with other Dapr API building blocks. For example, a workflow can call another service with service invocation or retrieve secrets, providing flexibility and portability. \ No newline at end of file diff --git a/daprdocs/content/en/developing-applications/building-blocks/configuration/configuration-api-overview.md b/daprdocs/content/en/developing-applications/building-blocks/configuration/configuration-api-overview.md index 2e95f6b49d1..3bda0d141a9 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/configuration/configuration-api-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/configuration/configuration-api-overview.md @@ -40,6 +40,11 @@ Want to put the Dapr configuration API to the test? Walk through the following q Want to skip the quickstarts? Not a problem. You can try out the configuration building block directly in your application to read and manage configuration data. After [Dapr is installed]({{< ref "getting-started/_index.md" >}}), you can begin using the configuration API starting with [the configuration how-to guide]({{< ref howto-manage-configuration.md >}}). +## Watch the demo + +Watch [this demo of using the Dapr Configuration building block](https://youtu.be/tNq-n1XQuLA?t=496) + + ## Next steps Follow these guides on: diff --git a/daprdocs/content/en/developing-applications/building-blocks/configuration/howto-manage-configuration.md b/daprdocs/content/en/developing-applications/building-blocks/configuration/howto-manage-configuration.md index b05722312b4..d09e5337cc4 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/configuration/howto-manage-configuration.md +++ b/daprdocs/content/en/developing-applications/building-blocks/configuration/howto-manage-configuration.md @@ -67,9 +67,11 @@ spec: ``` ## Retrieve Configuration Items -### Get configuration items using Dapr SDKs +### Get configuration items -{{< tabs ".NET" Java Python>}} +The following example shows how to get a saved configuration item using the Dapr Configuration API. + +{{< tabs ".NET" Java Python Go Javascript "HTTP API (BASH)" "HTTP API (Powershell)">}} {{% codetab %}} @@ -87,7 +89,6 @@ namespace ConfigurationApi { private static readonly string CONFIG_STORE_NAME = "configstore"; - [Obsolete] public static async Task Main(string[] args) { using var client = new DaprClientBuilder().Build(); @@ -105,7 +106,7 @@ namespace ConfigurationApi ```java //dependencies import io.dapr.client.DaprClientBuilder; -import io.dapr.client.DaprPreviewClient; +import io.dapr.client.DaprClient; import io.dapr.client.domain.ConfigurationItem; import io.dapr.client.domain.GetConfigurationRequest; import io.dapr.client.domain.SubscribeConfigurationRequest; @@ -116,7 +117,7 @@ import reactor.core.publisher.Mono; private static final String CONFIG_STORE_NAME = "configstore"; public static void main(String[] args) throws Exception { - try (DaprPreviewClient client = (new DaprClientBuilder()).buildPreviewClient()) { + try (DaprClient client = (new DaprClientBuilder()).build()) { List keys = new ArrayList<>(); keys.add("orderId1"); keys.add("orderId2"); @@ -150,80 +151,143 @@ with DaprClient() as d: {{% /codetab %}} -{{< /tabs >}} - -### Get configuration items using gRPC API +{{% codetab %}} -Using your [favorite language](https://grpc.io/docs/languages/), create a Dapr gRPC client from the [Dapr proto](https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/dapr.proto). The following examples show Java, C#, Python and Javascript clients. +```go +package main + +import ( + "context" + "fmt" + + dapr "github.com/dapr/go-sdk/client" +) + +func main() { + ctx := context.Background() + client, err := dapr.NewClient() + if err != nil { + panic(err) + } + items, err := client.GetConfigurationItems(ctx, "configstore", ["orderId1","orderId2"]) + if err != nil { + panic(err) + } + for key, item := range items { + fmt.Printf("get config: key = %s value = %s version = %s",key,(*item).Value, (*item).Version) + } +} +``` -{{< tabs Java Dotnet Python Javascript >}} +{{% /codetab %}} {{% codetab %}} -```java +```js +import { CommunicationProtocolEnum, DaprClient } from "@dapr/dapr"; + +// JS SDK does not support Configuration API over HTTP protocol yet +const protocol = CommunicationProtocolEnum.GRPC; +const host = process.env.DAPR_HOST ?? "localhost"; +const port = process.env.DAPR_GRPC_PORT ?? 3500; + +const DAPR_CONFIGURATION_STORE = "configstore"; +const CONFIGURATION_ITEMS = ["orderId1", "orderId2"]; + +async function main() { + const client = new DaprClient(host, port, protocol); + // Get config items from the config store + try { + const config = await client.configuration.get(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS); + Object.keys(config.items).forEach((key) => { + console.log("Configuration for " + key + ":", JSON.stringify(config.items[key])); + }); + } catch (error) { + console.log("Could not get config item, err:" + error); + process.exit(1); + } +} -Dapr.ServiceBlockingStub stub = Dapr.newBlockingStub(channel); -stub.GetConfigurationAlpha1(new GetConfigurationRequest{ StoreName = "redisconfigstore", Keys = new String[]{"myconfig"} }); +main().catch((e) => console.error(e)); ``` {{% /codetab %}} {{% codetab %}} -```csharp +Launch a dapr sidecar: -var call = client.GetConfigurationAlpha1(new GetConfigurationRequest { StoreName = "redisconfigstore", Keys = new String[]{"myconfig"} }); +```bash +dapr run --app-id orderprocessing --dapr-http-port 3601 ``` -{{% /codetab %}} - -{{% codetab %}} +In a separate terminal, get the configuration item saved earlier: -```python -response = stub.GetConfigurationAlpha1(request={ StoreName: 'redisconfigstore', Keys = ['myconfig'] }) +```bash +curl http://localhost:3601/v1.0/configuration/configstore?key=orderId1 ``` {{% /codetab %}} {{% codetab %}} -```javascript -client.GetConfigurationAlpha1({ StoreName: 'redisconfigstore', Keys = ['myconfig'] }) +Launch a Dapr sidecar: + +```bash +dapr run --app-id orderprocessing --dapr-http-port 3601 +``` + +In a separate terminal, get the configuration item saved earlier: + +```powershell +Invoke-RestMethod -Uri 'http://localhost:3601/v1.0/configuration/configstore?key=orderId1' ``` {{% /codetab %}} {{< /tabs >}} -### Watch configuration items using Dapr SDKs -{{< tabs "Dotnet Extension" "Dotnet Client">}} +### Subscribe to configuration item updates + +Below are code examples that leverage SDKs to subscribe to keys `[orderId1, orderId2]` using `configstore` store component. + +{{< tabs ".NET" "ASP.NET Core" Java Python Go Javascript>}} + {{% codetab %}} ```csharp -[Obsolete("Configuration API is an Alpha API. Obsolete will be removed when the API is no longer Alpha")] -public static void Main(string[] args) +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Dapr.Client; + +const string DAPR_CONFIGURATION_STORE = "configstore"; +var CONFIGURATION_KEYS = new List { "orderId1", "orderId2" }; +var client = new DaprClientBuilder().Build(); + +// Subscribe for configuration changes +SubscribeConfigurationResponse subscribe = await client.SubscribeConfiguration(DAPR_CONFIGURATION_STORE, CONFIGURATION_ITEMS); + +// Print configuration changes +await foreach (var items in subscribe.Source) { - CreateHostBuilder(args).Build().Run(); + // First invocation when app subscribes to config changes only returns subscription id + if (items.Keys.Count == 0) + { + Console.WriteLine("App subscribed to config changes with subscription id: " + subscribe.Id); + subscriptionId = subscribe.Id; + continue; + } + var cfg = System.Text.Json.JsonSerializer.Serialize(items); + Console.WriteLine("Configuration update " + cfg); } +``` -public static IHostBuilder CreateHostBuilder(string[] args) -{ - var client = new DaprClientBuilder().Build(); - return Host.CreateDefaultBuilder(args) - .ConfigureAppConfiguration(config => - { - // Get the initial value from the configuration component. - config.AddDaprConfigurationStore("redisconfig", new List() { "withdrawVersion" }, client, TimeSpan.FromSeconds(20)); +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: - // Watch the keys in the configuration component and update it in local configurations. - config.AddStreamingDaprConfigurationStore("redisconfig", new List() { "withdrawVersion", "source" }, client, TimeSpan.FromSeconds(20)); - }) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }); -} +```bash +dapr run --app-id orderprocessing -- dotnet run ``` {{% /codetab %}} @@ -231,105 +295,390 @@ public static IHostBuilder CreateHostBuilder(string[] args) {{% codetab %}} ```csharp -public IDictionary Data { get; set; } = new Dictionary(); -public string Id { get; set; } = string.Empty; +using System; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +using Dapr.Client; +using Dapr.Extensions.Configuration; +using System.Collections.Generic; +using System.Threading; -public async Task WatchConfiguration(DaprClient daprClient, string store, IReadOnlyList keys, Dictionary metadata, CancellationToken token = default) +namespace ConfigurationApi { - // Initialize the gRPC Stream that will provide configuration updates. - var subscribeConfigurationResponse = await daprClient.SubscribeConfiguration(store, keys, metadata, token); - - // The response contains a data source which is an IAsyncEnumerable, so it can be iterated through via an awaited foreach. - await foreach (var items in subscribeConfigurationResponse.Source.WithCancellation(token)) + public class Program { - // Each iteration from the stream can contain all the keys that were queried for, so it must be individually iterated through. - var data = new Dictionary(Data); - foreach (var item in items) + public static void Main(string[] args) + { + Console.WriteLine("Starting application."); + CreateHostBuilder(args).Build().Run(); + Console.WriteLine("Closing application."); + } + + /// + /// Creates WebHost Builder. + /// + /// Arguments. + /// Returns IHostbuilder. + public static IHostBuilder CreateHostBuilder(string[] args) { - // The Id in the response is used to unsubscribe. - Id = subscribeConfigurationResponse.Id; - data[item.Key] = item.Value; + var client = new DaprClientBuilder().Build(); + return Host.CreateDefaultBuilder(args) + .ConfigureAppConfiguration(config => + { + // Get the initial value and continue to watch it for changes. + config.AddDaprConfigurationStore("configstore", new List() { "orderId1","orderId2" }, client, TimeSpan.FromSeconds(20)); + config.AddStreamingDaprConfigurationStore("configstore", new List() { "orderId1","orderId2" }, client, TimeSpan.FromSeconds(20)); + + }) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }); } - Data = data; } } ``` -{{% /codetab %}} -{{< /tabs >}} +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: + +```bash +dapr run --app-id orderprocessing -- dotnet run +``` -### Watch configuration items using gRPC API +{{% /codetab %}} -Create a Dapr gRPC client from the [Dapr proto](https://github.com/dapr/dapr/blob/master/dapr/proto/runtime/v1/dapr.proto) using your [preferred language](https://grpc.io/docs/languages/). Use the `SubscribeConfigurationAlpha1` proto method on your client stub to start subscribing to events. The method accepts the following request object: +{{% codetab %}} -```proto -message SubscribeConfigurationRequest { - // The name of configuration store. - string store_name = 1; +```java +import io.dapr.client.DaprClientBuilder; +import io.dapr.client.DaprClient; +import io.dapr.client.domain.ConfigurationItem; +import io.dapr.client.domain.GetConfigurationRequest; +import io.dapr.client.domain.SubscribeConfigurationRequest; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; - // Optional. The key of the configuration item to fetch. - // If set, only query for the specified configuration items. - // Empty list means fetch all. - repeated string keys = 2; +//code +private static final String CONFIG_STORE_NAME = "configstore"; +private static String subscriptionId = null; - // The metadata which will be sent to configuration store components. - map metadata = 3; +public static void main(String[] args) throws Exception { + try (DaprClient client = (new DaprClientBuilder()).build()) { + // Subscribe for config changes + List keys = new ArrayList<>(); + keys.add("orderId1"); + keys.add("orderId2"); + Flux subscription = client.subscribeConfiguration(DAPR_CONFIGURATON_STORE,keys); + + // Read config changes for 20 seconds + subscription.subscribe((response) -> { + // First ever response contains the subscription id + if (response.getItems() == null || response.getItems().isEmpty()) { + subscriptionId = response.getSubscriptionId(); + System.out.println("App subscribed to config changes with subscription id: " + subscriptionId); + } else { + response.getItems().forEach((k, v) -> { + System.out.println("Configuration update for " + k + ": {'value':'" + v.getValue() + "'}"); + }); + } + }); + Thread.sleep(20000); + } } ``` -Using this method, you can subscribe to changes in specific keys for a given configuration store. gRPC streaming varies widely based on language - see the [gRPC examples here](https://grpc.io/docs/languages/) for usage. +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: -Below are the examples in sdks: +```bash +dapr run --app-id orderprocessing -- -- mvn spring-boot:run -{{< tabs Python>}} +{{% /codetab %}} {{% codetab %}} + ```python #dependencies -import asyncio from dapr.clients import DaprClient #code -async def executeConfiguration(): + +def handler(id: str, resp: ConfigurationResponse): + for key in resp.items: + print(f"Subscribed item received key={key} value={resp.items[key].value} " + f"version={resp.items[key].version} " + f"metadata={resp.items[key].metadata}", flush=True) + +def executeConfiguration(): with DaprClient() as d: - CONFIG_STORE_NAME = 'configstore' - key = 'orderId' - # Subscribe to configuration by key. - configuration = await d.subscribe_configuration(store_name=CONFIG_STORE_NAME, keys=[key], config_metadata={}) - if configuration != None: - items = configuration.get_items() - for item in items: - print(f"Subscribe key={item.key} value={item.value} version={item.version}", flush=True) - else: - print("Nothing yet") -asyncio.run(executeConfiguration()) + storeName = 'configurationstore' + keys = ['orderId1', 'orderId2'] + id = d.subscribe_configuration(store_name=storeName, keys=keys, + handler=handler, config_metadata={}) + print("Subscription ID is", id, flush=True) + sleep(20) + +executeConfiguration() ``` +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: + ```bash -dapr run --app-id orderprocessing --resources-path components/ -- python3 OrderProcessingService.py +dapr run --app-id orderprocessing -- python3 OrderProcessingService.py +``` + +{{% /codetab %}} + +{{% codetab %}} + +```go +package main + +import ( + "context" + "fmt" + "time" + + dapr "github.com/dapr/go-sdk/client" +) + +func main() { + ctx := context.Background() + client, err := dapr.NewClient() + if err != nil { + panic(err) + } + subscribeID, err := client.SubscribeConfigurationItems(ctx, "configstore", []string{"orderId1", "orderId2"}, func(id string, items map[string]*dapr.ConfigurationItem) { + for k, v := range items { + fmt.Printf("get updated config key = %s, value = %s version = %s \n", k, v.Value, v.Version) + } + }) + if err != nil { + panic(err) + } + time.Sleep(20*time.Second) +} +``` + +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: + +```bash +dapr run --app-id orderprocessing -- go run main.go +``` + +{{% /codetab %}} + +{{% codetab %}} + +```js +import { CommunicationProtocolEnum, DaprClient } from "@dapr/dapr"; + +// JS SDK does not support Configuration API over HTTP protocol yet +const protocol = CommunicationProtocolEnum.GRPC; +const host = process.env.DAPR_HOST ?? "localhost"; +const port = process.env.DAPR_GRPC_PORT ?? 3500; + +const DAPR_CONFIGURATION_STORE = "configstore"; +const CONFIGURATION_ITEMS = ["orderId1", "orderId2"]; + +async function main() { + const client = new DaprClient(host, port, protocol); + // Subscribe to config updates + try { + const stream = await client.configuration.subscribeWithKeys( + DAPR_CONFIGURATION_STORE, + CONFIGURATION_ITEMS, + (config) => { + console.log("Configuration update", JSON.stringify(config.items)); + } + ); + // Unsubscribe to config updates and exit app after 20 seconds + setTimeout(() => { + stream.stop(); + console.log("App unsubscribed to config changes"); + process.exit(0); + }, 20000); + } catch (error) { + console.log("Error subscribing to config updates, err:" + error); + process.exit(1); + } +} +main().catch((e) => console.error(e)); +``` + +Navigate to the directory containing the above code, then run the following command to launch both a Dapr sidecar and the subscriber application: + +```bash +dapr run --app-id orderprocessing --app-protocol grpc --dapr-grpc-port 3500 -- node index.js ``` {{% /codetab %}} {{< /tabs >}} -#### Stop watching configuration items -After you've subscribed to watch configuration items, the gRPC-server stream starts. Since this stream thread does not close itself, you have to explicitly call the `UnSubscribeConfigurationRequest` API to unsubscribe. This method accepts the following request object: +### Unsubscribe from configuration item updates + +After you've subscribed to watch configuration items, you will receive updates for all of the subscribed keys. To stop receiving updates, you need to explicitly call the unsubscribe API. + +Following are the code examples showing how you can unsubscribe to configuration updates using unsubscribe API. + +{{< tabs ".NET" Java Python Go Javascript "HTTP API (BASH)" "HTTP API (Powershell)">}} + +{{% codetab %}} +```csharp +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Dapr.Client; + +const string DAPR_CONFIGURATION_STORE = "configstore"; +var client = new DaprClientBuilder().Build(); + +// Unsubscribe to config updates and exit the app +async Task unsubscribe(string subscriptionId) +{ + try + { + await client.UnsubscribeConfiguration(DAPR_CONFIGURATION_STORE, subscriptionId); + Console.WriteLine("App unsubscribed from config changes"); + Environment.Exit(0); + } + catch (Exception ex) + { + Console.WriteLine("Error unsubscribing from config updates: " + ex.Message); + } +} +``` +{{% /codetab %}} + +{{% codetab %}} +```java +import io.dapr.client.DaprClientBuilder; +import io.dapr.client.DaprClient; +import io.dapr.client.domain.ConfigurationItem; +import io.dapr.client.domain.GetConfigurationRequest; +import io.dapr.client.domain.SubscribeConfigurationRequest; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +//code +private static final String CONFIG_STORE_NAME = "configstore"; +private static String subscriptionId = null; + +public static void main(String[] args) throws Exception { + try (DaprClient client = (new DaprClientBuilder()).build()) { + // Unsubscribe from config changes + UnsubscribeConfigurationResponse unsubscribe = client + .unsubscribeConfiguration(subscriptionId, DAPR_CONFIGURATON_STORE).block(); + if (unsubscribe.getIsUnsubscribed()) { + System.out.println("App unsubscribed to config changes"); + } else { + System.out.println("Error unsubscribing to config updates, err:" + unsubscribe.getMessage()); + } + } catch (Exception e) { + System.out.println("Error unsubscribing to config updates," + e.getMessage()); + System.exit(1); + } +} +``` +{{% /codetab %}} + +{{% codetab %}} +```python +import asyncio +import time +import logging +from dapr.clients import DaprClient +subscriptionID = "" + +with DaprClient() as d: + isSuccess = d.unsubscribe_configuration(store_name='configstore', id=subscriptionID) + print(f"Unsubscribed successfully? {isSuccess}", flush=True) +``` +{{% /codetab %}} + +{{% codetab %}} +```go +package main + +import ( + "context" + "encoding/json" + "fmt" + "log" + "os" + "time" + + dapr "github.com/dapr/go-sdk/client" +) + +var DAPR_CONFIGURATION_STORE = "configstore" +var subscriptionID = "" + +func main() { + client, err := dapr.NewClient() + if err != nil { + log.Panic(err) + } + ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() + if err := client.UnsubscribeConfigurationItems(ctx, DAPR_CONFIGURATION_STORE , subscriptionID); err != nil { + panic(err) + } +} +``` +{{% /codetab %}} -```proto -// UnSubscribeConfigurationRequest is the message to stop watching the key-value configuration. -message UnSubscribeConfigurationRequest { - // The name of configuration store. - string store_name = 1; - // Optional. The keys of the configuration item to stop watching. - // Store_name and keys should match previous SubscribeConfigurationRequest's keys and store_name. - // Once invoked, the subscription that is watching update for the key-value event is stopped - repeated string keys = 2; +{{% codetab %}} +```js +import { CommunicationProtocolEnum, DaprClient } from "@dapr/dapr"; + +// JS SDK does not support Configuration API over HTTP protocol yet +const protocol = CommunicationProtocolEnum.GRPC; +const host = process.env.DAPR_HOST ?? "localhost"; +const port = process.env.DAPR_GRPC_PORT ?? 3500; + +const DAPR_CONFIGURATION_STORE = "configstore"; +const CONFIGURATION_ITEMS = ["orderId1", "orderId2"]; + +async function main() { + const client = new DaprClient(host, port, protocol); + + try { + const stream = await client.configuration.subscribeWithKeys( + DAPR_CONFIGURATION_STORE, + CONFIGURATION_ITEMS, + (config) => { + console.log("Configuration update", JSON.stringify(config.items)); + } + ); + setTimeout(() => { + // Unsubscribe to config updates + stream.stop(); + console.log("App unsubscribed to config changes"); + process.exit(0); + }, 20000); + } catch (error) { + console.log("Error subscribing to config updates, err:" + error); + process.exit(1); + } } + +main().catch((e) => console.error(e)); +``` +{{% /codetab %}} + +{{% codetab %}} +```bash +curl 'http://localhost:/v1.0/configuration/configstore//unsubscribe' ``` +{{% /codetab %}} -Using this unsubscribe method, you can stop watching configuration update events. Dapr locates the subscription stream based on the `store_name` and any optional keys supplied and closes it. +{{% codetab %}} +```powershell +Invoke-RestMethod -Uri 'http://localhost:/v1.0/configuration/configstore//unsubscribe' +``` +{{% /codetab %}} ## Next steps -* Read [configuration API overview]({{< ref configuration-api-overview.md >}}) \ No newline at end of file +* Read [configuration API overview]({{< ref configuration-api-overview.md >}}) diff --git a/daprdocs/content/en/getting-started/tutorials/get-started-component.md b/daprdocs/content/en/getting-started/tutorials/get-started-component.md index 9f5d6f6bc9f..9f460ed0e7d 100644 --- a/daprdocs/content/en/getting-started/tutorials/get-started-component.md +++ b/daprdocs/content/en/getting-started/tutorials/get-started-component.md @@ -16,17 +16,7 @@ In this tutorial, you will create a component definition file to interact with t ## Step 1: Create a JSON secret store -Dapr supports [many types of secret stores]({{< ref supported-secret-stores >}}), but for this tutorial, create a local JSON file named `mysecrets.json` with the following secret: - -```json -{ - "my-secret" : "I'm Batman" -} -``` - -## Step 2: Create a secret store Dapr component - -1. Create a new directory named `my-components` to hold the new component file: +1. Create a new directory named `my-components` to hold the new secret and component file: ```bash mkdir my-components @@ -38,6 +28,16 @@ Dapr supports [many types of secret stores]({{< ref supported-secret-stores >}}) cd my-components ``` +1. Dapr supports [many types of secret stores]({{< ref supported-secret-stores >}}), but for this tutorial, create a local JSON file named `mysecrets.json` with the following secret: + +```json +{ + "my-secret" : "I'm Batman" +} +``` + +## Step 2: Create a secret store Dapr component + 1. Create a new file `localSecretStore.yaml` with the following contents: ```yaml @@ -51,13 +51,13 @@ Dapr supports [many types of secret stores]({{< ref supported-secret-stores >}}) version: v1 metadata: - name: secretsFile - value: /mysecrets.json + value: ./mysecrets.json - name: nestedSeparator value: ":" ``` In the above file definition: -- `type: secretstores.local.file` tells Dapr to use the local file component as a secret store. +- `type: secretstores.local.file` tells Dapr to use the local file component as a secret store. - The metadata fields provide component-specific information needed to work with this component. In this case, the secret store JSON path is relative to where you call `dapr run`. ## Step 3: Run the Dapr sidecar @@ -65,7 +65,7 @@ In the above file definition: Launch a Dapr sidecar that will listen on port 3500 for a blank application named `myapp`: ```bash -dapr run --app-id myapp --dapr-http-port 3500 --resources-path ./my-components +dapr run --app-id myapp --dapr-http-port 3500 --resources-path . ``` {{% alert title="Tip" color="primary" %}} @@ -104,4 +104,4 @@ Invoke-RestMethod -Uri 'http://localhost:3500/v1.0/secrets/my-secret-store/my-se {"my-secret":"I'm Batman"} ``` -{{< button text="Next step: Set up a Pub/sub broker >>" page="pubsub-quickstart" >}} \ No newline at end of file +{{< button text="Next step: Set up a Pub/sub broker >>" page="pubsub-quickstart" >}} diff --git a/daprdocs/content/en/reference/api/configuration_api.md b/daprdocs/content/en/reference/api/configuration_api.md index 6f611f3c87e..a1d8784724e 100644 --- a/daprdocs/content/en/reference/api/configuration_api.md +++ b/daprdocs/content/en/reference/api/configuration_api.md @@ -13,7 +13,7 @@ This endpoint lets you get configuration from a store. ### HTTP Request ``` -GET http://localhost:/v1.0-alpha1/configuration/ +GET http://localhost:/v1.0/configuration/ ``` #### URL Parameters @@ -29,13 +29,13 @@ If no query parameters are provided, all configuration items are returned. To specify the keys of the configuration items to get, use one or more `key` query parameters. For example: ``` -GET http://localhost:/v1.0-alpha1/configuration/mystore?key=config1&key=config2 +GET http://localhost:/v1.0/configuration/mystore?key=config1&key=config2 ``` To retrieve all configuration items: ``` -GET http://localhost:/v1.0-alpha1/configuration/mystore +GET http://localhost:/v1.0/configuration/mystore ``` #### Request Body @@ -59,7 +59,7 @@ JSON-encoded value of key/value pairs for each configuration item. ### Example ```shell -curl -X GET 'http://localhost:3500/v1.0-alpha1/configuration/mystore?key=myConfigKey' +curl -X GET 'http://localhost:3500/v1.0/configuration/mystore?key=myConfigKey' ``` > The above command returns the following JSON: @@ -75,7 +75,7 @@ This endpoint lets you subscribe to configuration changes. Notifications happen ### HTTP Request ``` -GET http://localhost:/v1.0-alpha1/configuration//subscribe +GET http://localhost:/v1.0/configuration//subscribe ``` #### URL Parameters @@ -91,13 +91,13 @@ If no query parameters are provided, all configuration items are subscribed to. To specify the keys of the configuration items to subscribe to, use one or more `key` query parameters. For example: ``` -GET http://localhost:/v1.0-alpha1/configuration/mystore/subscribe?key=config1&key=config2 +GET http://localhost:/v1.0/configuration/mystore/subscribe?key=config1&key=config2 ``` To subscribe to all changes: ``` -GET http://localhost:/v1.0-alpha1/configuration/mystore/subscribe +GET http://localhost:/v1.0/configuration/mystore/subscribe ``` #### Request Body @@ -121,7 +121,7 @@ JSON-encoded value ### Example ```shell -curl -X GET 'http://localhost:3500/v1.0-alpha1/configuration/mystore/subscribe?key=myConfigKey' +curl -X GET 'http://localhost:3500/v1.0/configuration/mystore/subscribe?key=myConfigKey' ``` > The above command returns the following JSON: @@ -141,7 +141,7 @@ This endpoint lets you unsubscribe to configuration changes. ### HTTP Request ``` -GET http://localhost:/v1.0-alpha1/configuration///unsubscribe +GET http://localhost:/v1.0/configuration///unsubscribe ``` #### URL Parameters @@ -181,7 +181,7 @@ Code | Description ### Example ```shell -curl -X GET 'http://localhost:3500/v1.0-alpha1/configuration/mystore/bf3aa454-312d-403c-af95-6dec65058fa2/unsubscribe' +curl -X GET 'http://localhost:3500/v1.0/configuration/mystore/bf3aa454-312d-403c-af95-6dec65058fa2/unsubscribe' ``` ## Optional application (user code) routes diff --git a/daprdocs/content/en/reference/components-reference/supported-configuration-stores/azure-appconfig-configuration-store.md b/daprdocs/content/en/reference/components-reference/supported-configuration-stores/azure-appconfig-configuration-store.md index 490b75d6168..4d2eeaea528 100644 --- a/daprdocs/content/en/reference/components-reference/supported-configuration-stores/azure-appconfig-configuration-store.md +++ b/daprdocs/content/en/reference/components-reference/supported-configuration-stores/azure-appconfig-configuration-store.md @@ -100,7 +100,7 @@ The Azure App Configuration store component supports the following optional `lab The label can be populated using query parameters in the request URL: ```bash -GET curl http://localhost:/v1.0-alpha1/configuration/?key=&metadata.label=