mirror of https://github.com/dapr/docs.git
Merge branch 'v1.7' into bindings_quickstarts
This commit is contained in:
commit
3054df7f51
|
@ -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 >}}).
|
||||
|
|
|
@ -204,7 +204,19 @@ public async Task<ActionResult<Stock>> 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<Void> handleMessage(@RequestBody(required = false) CloudEvent<String> 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 %}}
|
||||
|
|
|
@ -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]({{<ref secrets-overview>}}). 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.
|
||||
|
|
|
@ -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]({{<ref secrets-scopes>}})
|
||||
|
||||
## 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 >}}).
|
||||
|
||||
|
||||
|
|
|
@ -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 >}}).
|
||||
|
|
|
@ -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]({{< ref bindings-quickstart.md >}}) | Use Dapr's input and output bindings to schedule a database insert job. |
|
||||
| Actors | Coming soon. |
|
||||
| Observability | Coming soon. |
|
||||
| Secrets Management | Coming soon. |
|
||||
| Configuration | Coming soon. |
|
|
@ -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"
|
||||
---
|
||||
|
||||
|
|
|
@ -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" >}}
|
||||
<!-- Python -->
|
||||
{{% 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/).
|
||||
<!-- IGNORE_LINKS -->
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||
<!-- END_IGNORE -->
|
||||
|
||||
### 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 %}}
|
||||
|
||||
<!-- JavaScript -->
|
||||
{{% 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/).
|
||||
<!-- IGNORE_LINKS -->
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||
<!-- END_IGNORE -->
|
||||
|
||||
### 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 %}}
|
||||
|
||||
<!-- .NET -->
|
||||
{{% 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).
|
||||
<!-- IGNORE_LINKS -->
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||
<!-- END_IGNORE -->
|
||||
|
||||
### 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 %}}
|
||||
|
||||
<!-- Java -->
|
||||
{{% 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.
|
||||
<!-- IGNORE_LINKS -->
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||
<!-- END_IGNORE -->
|
||||
|
||||
### 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<String, String> 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 %}}
|
||||
|
||||
<!-- Go -->
|
||||
{{% 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/).
|
||||
<!-- IGNORE_LINKS -->
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop)
|
||||
<!-- END_IGNORE -->
|
||||
|
||||
### 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" >}}
|
|
@ -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"
|
||||
---
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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 >}}).
|
||||
|
|
|
@ -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 >}})
|
||||
|
|
|
@ -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"
|
||||
---
|
||||
|
|
|
@ -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 >}})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue