From c113088552a5dc97cc559b4cc2bdea1699209c21 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Wed, 1 Jun 2022 16:50:07 -0500 Subject: [PATCH 01/10] [Quickstart] Secrets Mgmt (#2470) * initial draft Signed-off-by: Hannah Hunter * link to quickstart from overview and howto Signed-off-by: Hannah Hunter * add go example Signed-off-by: Hannah Hunter * forgot go tab Signed-off-by: Hannah Hunter * small change Signed-off-by: Hannah Hunter Co-authored-by: Mark Fussell --- .../building-blocks/secrets/howto-secrets.md | 5 + .../secrets/secrets-overview.md | 15 + .../en/getting-started/quickstarts/_index.md | 4 +- .../quickstarts/pubsub-quickstart.md | 2 +- .../quickstarts/secrets-quickstart.md | 578 ++++++++++++++++++ .../serviceinvocation-quickstart.md | 2 +- .../quickstarts/statemanagement-quickstart.md | 4 +- 7 files changed, 604 insertions(+), 6 deletions(-) create mode 100644 daprdocs/content/en/getting-started/quickstarts/secrets-quickstart.md diff --git a/daprdocs/content/en/developing-applications/building-blocks/secrets/howto-secrets.md b/daprdocs/content/en/developing-applications/building-blocks/secrets/howto-secrets.md index 015553e26..3234b883e 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/secrets/howto-secrets.md +++ b/daprdocs/content/en/developing-applications/building-blocks/secrets/howto-secrets.md @@ -8,6 +8,11 @@ description: "Use the secret store building block to securely retrieve a secret" This article provides guidance on using Dapr's secrets API in your code to leverage the [secrets store building block]({{}}). The secrets API allows you to easily retrieve secrets in your application code from a configured secret store. +{{% alert title="Note" color="primary" %}} + If you haven't already, [try out the secrets management quickstart]({{< ref secrets-quickstart.md >}}) for a quick walk-through on how to retrieve a secret. + +{{% /alert %}} + ## Example The below code example loosely describes an application that processes orders. In the example, there is an order processing service, which has a Dapr sidecar. The order processing service uses Dapr to store a secret in a local secret store. diff --git a/daprdocs/content/en/developing-applications/building-blocks/secrets/secrets-overview.md b/daprdocs/content/en/developing-applications/building-blocks/secrets/secrets-overview.md index 044510bb5..1c14fa812 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/secrets/secrets-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/secrets/secrets-overview.md @@ -54,4 +54,19 @@ For more information read [referencing secret stores in components]({{< ref comp To provide more granular control on access to secrets, Dapr provides the ability to define scopes and restricting access permissions. Learn more about [using secret scoping]({{}}) +## Try out service management + +### Quickstarts and tutorials + +Want to put the Dapr secrets management API to the test? Walk through the following quickstart and tutorials to see Dapr secrets in action: + +| Quickstart/tutorial | Description | +| ------------------- | ----------- | +| [Secrets management quickstart]({{< ref secrets-quickstart.md >}}) | Retrieve secrets in the application code from a configured secret store using the secrets management API. | +| [Secret Store tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/secretstore) | Demonstrates the use of Dapr Secrets API to access secret stores. | + +### Start managing secrets directly in your app + +Want to skip the quickstarts? Not a problem. You can try out the secret management building block directly in your application to retrieve and manage secrets. After [Dapr is installed]({{< ref "getting-started/_index.md" >}}), you can begin using the secrets management API starting with [the secrets how-to guide]({{< ref howto-secrets.md >}}). + diff --git a/daprdocs/content/en/getting-started/quickstarts/_index.md b/daprdocs/content/en/getting-started/quickstarts/_index.md index 39c106fcd..c8942f7c4 100644 --- a/daprdocs/content/en/getting-started/quickstarts/_index.md +++ b/daprdocs/content/en/getting-started/quickstarts/_index.md @@ -23,10 +23,10 @@ Hit the ground running with our Dapr quickstarts, complete with code samples aim | Quickstarts | Description | | ----------- | ----------- | | [Service Invocation]({{< ref serviceinvocation-quickstart.md >}}) | Call a method on another service using the service invocation API. | -| [Publish and Subscribe]({{< ref pubsub-quickstart.md >}}) | Send and receive messages using the publish and subscribe API. | | [State Management]({{< ref statemanagement-quickstart.md >}}) | Create stateful applications using the state management API. | +| [Publish and Subscribe]({{< ref pubsub-quickstart.md >}}) | Send and receive messages using the publish and subscribe API. | +| [Secrets Management]({{< ref secrets-quickstart.md >}}) | Retrieve secrets in the application code from a configured secret store using the secrets management API. | | Bindings | Coming soon. | | Actors | Coming soon. | | Observability | Coming soon. | -| Secrets Management | Coming soon. | | Configuration | Coming soon. | \ No newline at end of file diff --git a/daprdocs/content/en/getting-started/quickstarts/pubsub-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/pubsub-quickstart.md index 14edc3ac4..d7e25abbe 100644 --- a/daprdocs/content/en/getting-started/quickstarts/pubsub-quickstart.md +++ b/daprdocs/content/en/getting-started/quickstarts/pubsub-quickstart.md @@ -2,7 +2,7 @@ type: docs title: "Quickstart: Publish and Subscribe" linkTitle: "Publish and Subscribe" -weight: 70 +weight: 73 description: "Get started with Dapr's Publish and Subscribe building block" --- diff --git a/daprdocs/content/en/getting-started/quickstarts/secrets-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/secrets-quickstart.md new file mode 100644 index 000000000..775fffe4c --- /dev/null +++ b/daprdocs/content/en/getting-started/quickstarts/secrets-quickstart.md @@ -0,0 +1,578 @@ +--- +type: docs +title: "Quickstart: Secrets Management" +linkTitle: "Secrets Management" +weight: 74 +description: "Get started with Dapr's Secrets Management building block" +--- + +Dapr provides a dedicated secrets API that allows developers to retrieve secrets from a secrets store. In this quickstart, you: + +1. Run a microservice with a secret store component. +1. Retrieve secrets using the Dapr secrets API in the application code. + +Select your preferred language-specific Dapr SDK before proceeding with the Quickstart. + +{{< tabs "Python" "JavaScript" ".NET" "Java" "Go" >}} + +{{% codetab %}} + +### Pre-requisites + +For this example, you will need: + +- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started). +- [Python 3.7+ installed](https://www.python.org/downloads/). + +- [Docker Desktop](https://www.docker.com/products/docker-desktop) + + +### Step 1: Set up the environment + +Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/secrets_management). + +```bash +git clone https://github.com/dapr/quickstarts.git +``` + +### Step 2: Retrieve the secret + +In a terminal window, navigate to the `order-processor` directory. + +```bash +cd secrets_management/python/sdk/order-processor +``` + +Install the dependencies: + +```bash +pip3 install -r requirements.txt +``` + +Run the `order-processor` service alongside a Dapr sidecar. + +```bash +dapr run --app-id order-processor --components-path ../../../components/ -- python3 app.py +``` + +#### Behind the scenes + +**`order-processor` service** + +Notice how the `order-processor` service below points to: + +- The `DAPR_SECRET_STORE` defined in the `local-secret-store.yaml` component. +- The secret defined in `secrets.json`. + +```python +# app.py +DAPR_SECRET_STORE = 'localsecretstore' +SECRET_NAME = 'secret' +with DaprClient() as client: + secret = client.get_secret(store_name=DAPR_SECRET_STORE, key=SECRET_NAME) + logging.info('Fetched Secret: %s', secret.secret) +``` + +**`local-secret-store.yaml` component** + +`DAPR_SECRET_STORE` is defined in the `local-secret-store.yaml` component file, located in [secrets_management/components](https://github.com/dapr/quickstarts/blob/master/secrets_management/components/local-secret-store.yaml): + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: localsecretstore + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: secrets.json + - name: nestedSeparator + value: ":" +``` + +In the YAML file: + +- `metadata/name` is how your application references the component (called `DAPR_SECRET_STORE` in the code sample). +- `spec/metadata` defines the connection to the secret used by the component. + +**`secrets.json` file** + +`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/blob/master/secrets_management/python/sdk/order-processor/secrets.json): + +```json +{ + "secret": "YourPasskeyHere" +} +``` + +### Step 3: View the order-processor outputs + +As specified in the application code above, the `order-processor` service retrieves the secret via the Dapr secret store and displays it in the console. + +Order-processor output: + +``` +== APP == INFO:root:Fetched Secret: {'secret': 'YourPasskeyHere'} +``` + +{{% /codetab %}} + + +{{% codetab %}} + +### Pre-requisites + +For this example, you will need: + +- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started). +- [Latest Node.js installed](https://nodejs.org/download/). + +- [Docker Desktop](https://www.docker.com/products/docker-desktop) + + +### Step 1: Set up the environment + +Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/secrets_management). + +```bash +git clone https://github.com/dapr/quickstarts.git +``` + +### Step 2: Retrieve the secret + +In a terminal window, navigate to the `order-processor` directory. + +```bash +cd secrets_management/javascript/sdk/order-processor +``` + +Install the dependencies: + +```bash +npm install +``` + +Run the `order-processor` service alongside a Dapr sidecar. + +```bash +dapr run --app-id order-processor --components-path ../../../components/ -- npm start +``` + +#### Behind the scenes + +**`order-processor` service** + +Notice how the `order-processor` service below points to: + +- The `DAPR_SECRET_STORE` defined in the `local-secret-store.yaml` component. +- The secret defined in `secrets.json`. + +```javascript +// index.js +const DAPR_SECRET_STORE = "localsecretstore"; +const SECRET_NAME = "secret"; + +async function main() { + // ... + const secret = await client.secret.get(DAPR_SECRET_STORE, SECRET_NAME); + console.log("Fetched Secret: " + JSON.stringify(secret)); +} +``` + +**`local-secret-store.yaml` component** + +`DAPR_SECRET_STORE` is defined in the `local-secret-store.yaml` component file, located in [secrets_management/components](https://github.com/dapr/quickstarts/blob/master/secrets_management/components/local-secret-store.yaml): + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: localsecretstore + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: secrets.json + - name: nestedSeparator + value: ":" +``` + +In the YAML file: + +- `metadata/name` is how your application references the component (called `DAPR_SECRET_STORE` in the code sample). +- `spec/metadata` defines the connection to the secret used by the component. + +**`secrets.json` file** + +`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/javascript/sdk/order-processor](https://github.com/dapr/quickstarts/blob/master/secrets_management/javascript/sdk/order-processor/secrets.json): + +```json +{ + "secret": "YourPasskeyHere" +} +``` + +### Step 3: View the order-processor outputs + +As specified in the application code above, the `order-processor` service retrieves the secret via the Dapr secret store and displays it in the console. + +Order-processor output: + +``` +== APP == +== APP == > order-processor@1.0.0 start +== APP == > node index.js +== APP == +== APP == Fetched Secret: {"secret":"YourPasskeyHere"} +``` + +{{% /codetab %}} + + +{{% codetab %}} + +### Pre-requisites + +For this example, you will need: + +- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started). +- [.NET SDK or .NET 6 SDK installed](https://dotnet.microsoft.com/download). + +- [Docker Desktop](https://www.docker.com/products/docker-desktop) + + +### Step 1: Set up the environment + +Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/secrets_management). + +```bash +git clone https://github.com/dapr/quickstarts.git +``` + +### Step 2: Retrieve the secret + +In a terminal window, navigate to the `order-processor` directory. + +```bash +cd secrets_management/csharp/sdk/order-processor +``` + +Install the dependencies: + +```bash +dotnet restore +dotnet build +``` + +Run the `order-processor` service alongside a Dapr sidecar. + +```bash +dapr run --app-id order-processor --components-path ../../../components/ -- dotnet run +``` + +#### Behind the scenes + +**`order-processor` service** + +Notice how the `order-processor` service below points to: + +- The `DAPR_SECRET_STORE` defined in the `local-secret-store.yaml` component. +- The secret defined in `secrets.json`. + +```csharp +// Program.cs +const string DAPR_SECRET_STORE = "localsecretstore"; +const string SECRET_NAME = "secret"; +var client = new DaprClientBuilder().Build(); + +var secret = await client.GetSecretAsync(DAPR_SECRET_STORE, SECRET_NAME); +var secretValue = string.Join(", ", secret); +Console.WriteLine($"Fetched Secret: {secretValue}"); +``` + +**`local-secret-store.yaml` component** + +`DAPR_SECRET_STORE` is defined in the `local-secret-store.yaml` component file, located in [secrets_management/components](https://github.com/dapr/quickstarts/blob/master/secrets_management/components/local-secret-store.yaml): + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: localsecretstore + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: secrets.json + - name: nestedSeparator + value: ":" +``` + +In the YAML file: + +- `metadata/name` is how your application references the component (called `DAPR_SECRET_NAME` in the code sample). +- `spec/metadata` defines the connection to the secret used by the component. + +**`secrets.json` file** + +`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/csharp/sdk/order-processor](https://github.com/dapr/quickstarts/blob/master/secrets_management/csharp/sdk/order-processor/secrets.json): + +```json +{ + "secret": "YourPasskeyHere" +} +``` + +### Step 3: View the order-processor outputs + +As specified in the application code above, the `order-processor` service retrieves the secret via the Dapr secret store and displays it in the console. + +Order-processor output: + +``` +== APP == Fetched Secret: [secret, YourPasskeyHere] +``` + +{{% /codetab %}} + + +{{% codetab %}} + +### Pre-requisites + +For this example, you will need: + +- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started). +- Java JDK 11 (or greater): + - [Oracle JDK](https://www.oracle.com/technetwork/java/javase/downloads/index.html#JDK11), or + - [OpenJDK](https://jdk.java.net/13/) +- [Apache Maven](https://maven.apache.org/install.html), version 3.x. + +- [Docker Desktop](https://www.docker.com/products/docker-desktop) + + +### Step 1: Set up the environment + +Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/secrets_management). + +```bash +git clone https://github.com/dapr/quickstarts.git +``` + +### Step 2: Retrieve the secret + +In a terminal window, navigate to the `order-processor` directory. + +```bash +cd secrets_management/java/sdk/order-processor +``` + +Install the dependencies: + +```bash +mvn clean install +``` + +Run the `order-processor` service alongside a Dapr sidecar. + +```bash +dapr run --app-id order-processor --components-path ../../../components/ -- java -jar target/order-processor-0.0.1-SNAPSHOT.jar +``` + +#### Behind the scenes + +**`order-processor` service** + +Notice how the `order-processor` service below points to: + +- The `DAPR_SECRET_STORE` defined in the `local-secret-store.yaml` component. +- The secret defined in `secrets.json`. + +```java +// OrderProcessingServiceApplication.java +private static final String SECRET_STORE_NAME = "localsecretstore"; +// ... + Map secret = client.getSecret(SECRET_STORE_NAME, "secret").block(); + System.out.println("Fetched Secret: " + secret); +``` + +**`local-secret-store.yaml` component** + +`DAPR_SECRET_STORE` is defined in the `local-secret-store.yaml` component file, located in [secrets_management/components](https://github.com/dapr/quickstarts/blob/master/secrets_management/components/local-secret-store.yaml): + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: localsecretstore + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: secrets.json + - name: nestedSeparator + value: ":" +``` + +In the YAML file: + +- `metadata/name` is how your application references the component (called `DAPR_SECRET_NAME` in the code sample). +- `spec/metadata` defines the connection to the secret used by the component. + +**`secrets.json` file** + +`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/blob/master/secrets_management/java/sdk/order-processor/secrets.json): + +```json +{ + "secret": "YourPasskeyHere" +} +``` + +### Step 3: View the order-processor outputs + +As specified in the application code above, the `order-processor` service retrieves the secret via the Dapr secret store and displays it in the console. + +Order-processor output: + +``` +== APP == Fetched Secret: {secret=YourPasskeyHere} +``` + +{{% /codetab %}} + + +{{% codetab %}} + +### Pre-requisites + +For this example, you will need: + +- [Dapr CLI and initialized environment](https://docs.dapr.io/getting-started). +- [Latest version of Go](https://go.dev/dl/). + +- [Docker Desktop](https://www.docker.com/products/docker-desktop) + + +### Step 1: Set up the environment + +Clone the [sample provided in the Quickstarts repo](https://github.com/dapr/quickstarts/tree/master/secrets_management). + +```bash +git clone https://github.com/dapr/quickstarts.git +``` + +### Step 2: Retrieve the secret + +In a terminal window, navigate to the `order-processor` directory. + +```bash +cd secrets_management/go/sdk/order-processor +``` + +Install the dependencies: + +```bash +pip3 install -r requirements.txt +``` + +Run the `order-processor` service alongside a Dapr sidecar. + +```bash +dapr run --app-id order-processor --components-path ../../../components/ -- go run app.go +``` + +#### Behind the scenes + +**`order-processor` service** + +Notice how the `order-processor` service below points to: + +- The `DAPR_SECRET_STORE` defined in the `local-secret-store.yaml` component. +- The secret defined in `secrets.json`. + +```go +const DAPR_SECRET_STORE = "localsecretstore" + const SECRET_NAME = "secret" + // ... + secret, err := client.GetSecret(ctx, DAPR_SECRET_STORE, SECRET_NAME, nil) + if secret != nil { + fmt.Println("Fetched Secret: ", secret[SECRET_NAME]) + } +``` + +**`local-secret-store.yaml` component** + +`DAPR_SECRET_STORE` is defined in the `local-secret-store.yaml` component file, located in [secrets_management/components](https://github.com/dapr/quickstarts/blob/master/secrets_management/components/local-secret-store.yaml): + +```yaml +apiVersion: dapr.io/v1alpha1 +kind: Component +metadata: + name: localsecretstore + namespace: default +spec: + type: secretstores.local.file + version: v1 + metadata: + - name: secretsFile + value: secrets.json + - name: nestedSeparator + value: ":" +``` + +In the YAML file: + +- `metadata/name` is how your application references the component (called `DAPR_SECRET_NAME` in the code sample). +- `spec/metadata` defines the connection to the secret used by the component. + +**`secrets.json` file** + +`SECRET_NAME` is defined in the `secrets.json` file, located in [secrets_management/python/sdk/order-processor](https://github.com/dapr/quickstarts/blob/master/secrets_management/java/sdk/order-processor/secrets.json): + +```json +{ + "secret": "YourPasskeyHere" +} +``` + +### Step 3: View the order-processor outputs + +As specified in the application code above, the `order-processor` service retrieves the secret via the Dapr secret store and displays it in the console. + +Order-processor output: + +``` +== APP == Fetched Secret: YourPasskeyHere +``` + +{{% /codetab %}} + +{{< /tabs >}} + +## Tell us what you think! + +We're continuously working to improve our Quickstart examples and value your feedback. Did you find this Quickstart helpful? Do you have suggestions for improvement? + +Join the discussion in our [discord channel](https://discord.gg/22ZtJrNe). + +## Next steps + +- Use Dapr Secrets Management with HTTP instead of an SDK. + - [Python](https://github.com/dapr/quickstarts/tree/master/secrets_management/python/http) + - [JavaScript](https://github.com/dapr/quickstarts/tree/master/secrets_management/javascript/http) + - [.NET](https://github.com/dapr/quickstarts/tree/master/secrets_management/csharp/http) + - [Java](https://github.com/dapr/quickstarts/tree/master/secrets_management/java/http) + - [Go](https://github.com/dapr/quickstarts/tree/master/secrets_management/go/http) +- Learn more about the [Secrets Management building block]({{< ref secrets-overview >}}) + +{{< button text="Explore Dapr tutorials >>" page="getting-started/tutorials/_index.md" >}} diff --git a/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md index dc9bd48e3..a4794774f 100644 --- a/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md +++ b/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md @@ -2,7 +2,7 @@ type: docs title: "Quickstart: Service Invocation" linkTitle: "Service Invocation" -weight: 70 +weight: 71 description: "Get started with Dapr's Service Invocation building block" --- diff --git a/daprdocs/content/en/getting-started/quickstarts/statemanagement-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/statemanagement-quickstart.md index 8c1428d6c..b605bf3f0 100644 --- a/daprdocs/content/en/getting-started/quickstarts/statemanagement-quickstart.md +++ b/daprdocs/content/en/getting-started/quickstarts/statemanagement-quickstart.md @@ -2,8 +2,8 @@ type: docs title: "Quickstart: State Management" linkTitle: "State Management" -weight: 70 -description: "Get started with Dapr's State Store" +weight: 72 +description: "Get started with Dapr's State Management building block" --- Let's take a look at Dapr's [State Management building block]({{< ref state-management >}}). In this Quickstart, you will save, get, and delete state using a Redis state store, but you can swap this out for any one of the [supported state stores]({{< ref supported-state-stores.md >}}). From 93a6a517ffc6de0b84e355e83f97f2bd5ab502ce Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Thu, 2 Jun 2022 13:58:11 -0500 Subject: [PATCH 02/10] attempt at java example (#2486) Signed-off-by: Hannah Hunter --- .../building-blocks/pubsub/subscription-methods.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/daprdocs/content/en/developing-applications/building-blocks/pubsub/subscription-methods.md b/daprdocs/content/en/developing-applications/building-blocks/pubsub/subscription-methods.md index 7c4d24019..e6506b7b2 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/pubsub/subscription-methods.md +++ b/daprdocs/content/en/developing-applications/building-blocks/pubsub/subscription-methods.md @@ -204,7 +204,19 @@ public async Task> HandleCheckout(Checkout checkout, [FromSe {{% codetab %}} ```java +private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); +@Topic(name = "checkout", pubsubName = "order_pub_sub") +@PostMapping(path = "/orders") +public Mono handleMessage(@RequestBody(required = false) CloudEvent cloudEvent) { + return Mono.fromRunnable(() -> { + try { + System.out.println("Subscriber received: " + cloudEvent.getData()); + System.out.println("Subscriber received: " + OBJECT_MAPPER.writeValueAsString(cloudEvent)); + } catch (Exception e) { + throw new RuntimeException(e); + } + }); ``` {{% /codetab %}} From 449bd584c49bbf3ff147e3dc6f48e5d9cc088c43 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Thu, 2 Jun 2022 14:17:21 -0500 Subject: [PATCH 03/10] fix link (#2489) Signed-off-by: Hannah Hunter --- .../building-blocks/pubsub/howto-publish-subscribe.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/pubsub/howto-publish-subscribe.md b/daprdocs/content/en/developing-applications/building-blocks/pubsub/howto-publish-subscribe.md index c11534932..fd5f3548b 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/pubsub/howto-publish-subscribe.md +++ b/daprdocs/content/en/developing-applications/building-blocks/pubsub/howto-publish-subscribe.md @@ -646,7 +646,7 @@ In order to tell Dapr that a message was processed successfully, return a `200 O ## Next steps -- Try the [pub/sub tutorial]({{https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub}}). +- Try the [pub/sub tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/pub-sub). - Learn about [messaging with CloudEvents]({{< ref pubsub-cloudevents.md >}}) and when you might want to [send messages without CloudEvents]({{< ref pubsub-raw.md >}}). - Review the list of [pub/sub components]({{< ref setup-pubsub >}}). - Read the [API reference]({{< ref pubsub_api.md >}}). From 0278d87ad0c4a79f1152b12ac9982117c6892e23 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Thu, 2 Jun 2022 17:54:19 -0500 Subject: [PATCH 04/10] update orderprocessor port (#2491) Signed-off-by: Hannah Hunter Co-authored-by: Mark Fussell --- .../getting-started/quickstarts/serviceinvocation-quickstart.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md index a4794774f..af2066c16 100644 --- a/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md +++ b/daprdocs/content/en/getting-started/quickstarts/serviceinvocation-quickstart.md @@ -420,7 +420,7 @@ mvn clean install Run the `order-processor` service alongside a Dapr sidecar. ```bash -dapr run --app-id order-processor --app-port 6001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar +dapr run --app-id order-processor --app-port 9001 --app-protocol http --dapr-http-port 3501 -- java -jar target/OrderProcessingService-0.0.1-SNAPSHOT.jar ``` ```java From f9acc469a9fbef5e838b8e2b2a5b09ca94521393 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:04:25 -0500 Subject: [PATCH 05/10] [State store component] Add clarification to Redis state store setup (#2492) * add suggested text Signed-off-by: Hannah Hunter * peer level Signed-off-by: Hannah Hunter Co-authored-by: Mark Fussell --- .../supported-state-stores/setup-redis.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-redis.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-redis.md index b2c352ea8..d4a91c105 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-redis.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-redis.md @@ -150,9 +150,10 @@ We can use [Helm](https://helm.sh/) to quickly create a Redis instance in our Ku {{< /tabs >}} -### Querying JSON objects +## Querying JSON objects (optional) + +In addition to supporting storing and querying state data as key/value pairs, the Redis state store optionally supports querying of JSON objects to meet more complex querying or filtering requirements. To enable this feature, the following steps are required: -The Redis state store supports querying of JSON objects. To enable this feature, the following steps are required: 1. The Redis store must support Redis modules and specifically both Redisearch and RedisJson. If you are deploying and running Redis then load [redisearch](https://oss.redis.com/redisearch/) and [redisjson](https://oss.redis.com/redisjson/) modules when deploying the Redis service. `` 2. Specify `queryIndexes` entry in the metadata of the component config. The value of the `queryIndexes` is a JSON array of the following format: From a4e070956d7dff9cab7508990386d8c37c771c38 Mon Sep 17 00:00:00 2001 From: Aaron Crawfis Date: Tue, 7 Jun 2022 21:22:30 -0700 Subject: [PATCH 06/10] Match linkTitle case for HTTP (#2480) Co-authored-by: Mark Fussell --- .../en/operations/configuration/increase-request-size.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/operations/configuration/increase-request-size.md b/daprdocs/content/en/operations/configuration/increase-request-size.md index 118dfaa3a..2faadecf0 100644 --- a/daprdocs/content/en/operations/configuration/increase-request-size.md +++ b/daprdocs/content/en/operations/configuration/increase-request-size.md @@ -1,7 +1,7 @@ --- type: docs title: "How-To: Handle large http body requests" -linkTitle: "Http request body size" +linkTitle: "HTTP request body size" weight: 6000 description: "Configure http requests that are bigger than 4 MB" --- From 5ba9f2a97ac9aa7c41262d47b757c3def7ab1f29 Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Thu, 9 Jun 2022 14:57:42 -0500 Subject: [PATCH 07/10] fix and move links (#2505) Signed-off-by: Hannah Hunter --- .../state-management/state-management-overview.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md index 1bf78f979..e7dd518f1 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md +++ b/daprdocs/content/en/developing-applications/building-blocks/state-management/state-management-overview.md @@ -89,11 +89,11 @@ Transactional state stores can be used to store actor state. To specify which st ### Querying state There are two ways to query the state: - * Using the [state management query API]({{< ref "#state-query-api" >}}) provided in Dapr runtime. - * Querying state store [directly]({{< ref "#query-state-store-directly" >}}) with the store's native SDK. + * Using the state management query API provided in Dapr runtime. + * Querying state store directly with the store's native SDK. #### Query API -The query API provides a way of querying the key/value data saved using state management in state stores regardless of underlying database or storage technology. It is an optional state management API. Using the state management query API you can filter, sort and paginate the key/value data. For more details read [How-To: Query state]({{< ref howto-state-query-api.md >}}). +The [query API]({{< ref "reference/api/state_api.md#query-state" >}}) provides a way of querying the key/value data saved using state management in state stores regardless of underlying database or storage technology. It is an optional state management API. Using the state management query API you can filter, sort and paginate the key/value data. For more details read [How-To: Query state]({{< ref howto-state-query-api.md >}}). #### Querying state store directly Dapr saves and retrieves state values without any transformation. You can query and aggregate state directly from the [underlying state store]({{< ref query-state-store >}}). From e7711c1d79430ce8ffcaf3b681f3493462cba61c Mon Sep 17 00:00:00 2001 From: Sarthak Sharma <48413781+sarsharma@users.noreply.github.com> Date: Fri, 10 Jun 2022 22:56:10 +0530 Subject: [PATCH 08/10] fix formatting and add response output (#2504) Signed-off-by: Sarthak Sharma Co-authored-by: Mark Fussell --- .../components-reference/supported-bindings/kafka.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/kafka.md b/daprdocs/content/en/reference/components-reference/supported-bindings/kafka.md index 249758d8e..67221c423 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/kafka.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/kafka.md @@ -37,6 +37,8 @@ spec: secretKeyRef: name: kafka-secrets key: saslPasswordSecret + - name: initialOffset # Optional. Used for input bindings. + value: "newest" - name: maxMessageBytes # Optional. value: 1024 - name: version # Optional. @@ -54,9 +56,9 @@ spec: | authRequired | Y | Input/Output | Enable [SASL](https://en.wikipedia.org/wiki/Simple_Authentication_and_Security_Layer) authentication with the Kafka brokers. | `"true"`, `"false"` | | saslUsername | N | Input/Output | The SASL username used for authentication. Only required if `authRequired` is set to `"true"`. | `"adminuser"` | | saslPassword | N | Input/Output | The SASL password used for authentication. Can be `secretKeyRef` to use a [secret reference]({{< ref component-secrets.md >}}). Only required if `authRequired` is set to `"true"`. | `""`, `"KeFg23!"` | -| initialOffset | N | The initial offset to use if no offset was previously committed. Should be "newest" or "oldest". Defaults to "newest". | `"oldest"` | +| initialOffset | N | Input | The initial offset to use if no offset was previously committed. Should be "newest" or "oldest". Defaults to "newest". | `"oldest"` | | maxMessageBytes | N | Input/Output | The maximum size in bytes allowed for a single Kafka message. Defaults to 1024. | `2048` | -| version | N | Kafka cluster version. Defaults to 1.0.0 | `1.0.0` +| version | N | Input/Output | Kafka cluster version. Defaults to 1.0.0 | `1.0.0` ## Binding support @@ -88,6 +90,10 @@ curl -X POST http://localhost:3500/v1.0/bindings/myKafka \ }' ``` +### Response + +An HTTP 204 (No Content) and empty body will be returned if successful. + ## Related links - [Basic schema for a Dapr component]({{< ref component-schema >}}) From 7eff7d880391888e2815cbd52c8052a9514ed845 Mon Sep 17 00:00:00 2001 From: CacheCoww Date: Tue, 14 Jun 2022 12:46:46 -0400 Subject: [PATCH 09/10] Add note to documentation to reference the podName attribute (#2523) Signed-off-by: CacheCoww --- daprdocs/content/en/operations/components/component-schema.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daprdocs/content/en/operations/components/component-schema.md b/daprdocs/content/en/operations/components/component-schema.md index 09fd461ea..0e4ab7822 100644 --- a/daprdocs/content/en/operations/components/component-schema.md +++ b/daprdocs/content/en/operations/components/component-schema.md @@ -67,6 +67,9 @@ spec: value: "false" ``` +The consumerID metadata values can also contain a `{podName}` tag that is replaced with the Kubernetes POD's name when the Dapr sidecar starts up. This can be used to have a persisted behavior where the ConsumerID does not change on restart when using StatefulSets in Kubernetes. + + ## Further reading - [Components concept]({{< ref components-concept.md >}}) - [Reference secrets in component definitions]({{< ref component-secrets.md >}}) From 4b1deaea54d4b38a554fbadc9c1c9078d66e9771 Mon Sep 17 00:00:00 2001 From: Tyson Lawrie Date: Thu, 16 Jun 2022 01:00:11 +1000 Subject: [PATCH 10/10] Added spec.metadata to example and note (#2527) Signed-off-by: Tyson Lawrie --- .../components-reference/supported-pubsub/setup-inmemory.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-inmemory.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-inmemory.md index 6ce033b3e..add1f9aa3 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-inmemory.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-inmemory.md @@ -20,8 +20,11 @@ metadata: spec: type: pubsub.in-memory version: v1 + metadata: [] ``` +> Note: in-memory does not require any specific metadata for the component to work, however spec.metadata is a required field. + ## Related links - [Basic schema for a Dapr component]({{< ref component-schema >}}) in the Related links section - Read [this guide]({{< ref "howto-publish-subscribe.md#step-2-publish-a-topic" >}}) for instructions on configuring pub/sub components