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 8630094a6..960a4aa5b 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 @@ -10,6 +10,11 @@ This guide demonstrates how to use Dapr's secrets API in your code to leverage t Diagram showing secrets management of example service +{{% 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 use the secrets API. + +{{% /alert %}} + ## Set up a secret store Before retrieving secrets in your application's code, you must configure a secret store component. This example configures a local secret store which uses a local JSON file to store secrets. diff --git a/daprdocs/content/en/developing-applications/building-blocks/service-invocation/howto-invoke-discover-services.md b/daprdocs/content/en/developing-applications/building-blocks/service-invocation/howto-invoke-discover-services.md index 2af48cbf3..453e85113 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/service-invocation/howto-invoke-discover-services.md +++ b/daprdocs/content/en/developing-applications/building-blocks/service-invocation/howto-invoke-discover-services.md @@ -10,7 +10,10 @@ This article demonstrates how to deploy services each with an unique application Diagram showing service invocation of example service -For a complete sample demonstrating service invocation, [walk through the service invocation quickstart](https://github.com/dapr/quickstarts/tree/master/service_invocation). +{{% alert title="Note" color="primary" %}} + If you haven't already, [try out the service invocation quickstart]({{< ref serviceinvocation-quickstart.md >}}) for a quick walk-through on how to use the service invocation API. + +{{% /alert %}} ## Choose an ID for your service diff --git a/daprdocs/content/en/getting-started/quickstarts/_index.md b/daprdocs/content/en/getting-started/quickstarts/_index.md index 7202a296d..dfd2d2d26 100644 --- a/daprdocs/content/en/getting-started/quickstarts/_index.md +++ b/daprdocs/content/en/getting-started/quickstarts/_index.md @@ -22,11 +22,11 @@ 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. | -| [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. | -| [Bindings]({{< ref bindings-quickstart.md >}}) | Schedule a database insert job using the input and output bindings API. | -| [Secrets Management]({{< ref secrets-quickstart.md >}}) | Retrieve secrets in the application code from a configured secret store using the secrets management API. | +| [Publish and Subscribe]({{< ref pubsub-quickstart.md >}}) | Asynchronous communication between two services using messaging. | +| [Service Invocation]({{< ref serviceinvocation-quickstart.md >}}) | Asynchronous communication between two services using HTTP. | +| [State Management]({{< ref statemanagement-quickstart.md >}}) | Store a service's data as key/value pairs in supported state stores. | +| [Bindings]({{< ref bindings-quickstart.md >}}) | Work with external systems using input bindings to respond to events and output bindings to call operations. | +| [Secrets Management]({{< ref secrets-quickstart.md >}}) | Securely fetch secrets. | | Actors | Coming soon. | | Observability | Coming soon. | | Configuration | Coming soon. | \ No newline at end of file diff --git a/daprdocs/content/en/getting-started/quickstarts/bindings-quickstart.md b/daprdocs/content/en/getting-started/quickstarts/bindings-quickstart.md index 65d87d993..9744488f4 100644 --- a/daprdocs/content/en/getting-started/quickstarts/bindings-quickstart.md +++ b/daprdocs/content/en/getting-started/quickstarts/bindings-quickstart.md @@ -100,22 +100,19 @@ The `batch-sdk` service uses the PostgreSQL output binding defined in the [`bind ```python with DaprClient() as d: - sqlCmd = ('insert into orders (orderid, customer, price) values' + - '(%s, \'%s\', %s)' % (order_line['orderid'], - order_line['customer'], - order_line['price'])) - payload = {'sql': sqlCmd} + sqlCmd = ('insert into orders (orderid, customer, price) values ' + + '(%s, \'%s\', %s)' % (order_line['orderid'], + order_line['customer'], + order_line['price'])) + payload = {'sql': sqlCmd} - print(sqlCmd, flush=True) + print(sqlCmd, flush=True) - try: - # Insert order using Dapr output binding via HTTP Post - resp = d.invoke_binding(binding_name=sql_binding, operation='exec', - binding_metadata=payload, data='') - return resp - except Exception as e: - print(e, flush=True) - raise SystemExit(e) + try: + # Insert order using Dapr output binding via HTTP Post + resp = d.invoke_binding(binding_name=sql_binding, operation='exec', + binding_metadata=payload, data='') + return resp ``` ### Step 4: View the output of the job @@ -499,22 +496,29 @@ dapr run --app-id batch-sdk --app-port 7002 --components-path ../../../component The code inside the `process_batch` function is executed every 10 seconds (defined in [`binding-cron.yaml`]({{< ref "#componentsbinding-cronyaml-component-file" >}}) in the `components` directory). The binding trigger looks for a route called via HTTP POST in your Flask application by the Dapr sidecar. ```csharp -Console.WriteLine("Processing batch.."); -string jsonFile = File.ReadAllText("../../orders.json"); -var ordersArray = JsonSerializer.Deserialize(jsonFile); +app.MapPost("/" + cronBindingName, async () => { +// ... +}); ``` The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table. ```csharp +// ... +string jsonFile = File.ReadAllText("../../../orders.json"); +var ordersArray = JsonSerializer.Deserialize(jsonFile); using var client = new DaprClientBuilder().Build(); - foreach(Order ord in ordersArray?.orders ?? new Order[] {}){ - var sqlText = $"insert into orders (orderid, customer, price) values ({ord.OrderId}, '{ord.Customer}', {ord.Price});"; - var command = new Dictionary(){ - {"sql", - sqlText} - }; - Console.WriteLine(sqlText); +foreach(Order ord in ordersArray?.orders ?? new Order[] {}){ + var sqlText = $"insert into orders (orderid, customer, price) values ({ord.OrderId}, '{ord.Customer}', {ord.Price});"; + var command = new Dictionary(){ + {"sql", + sqlText} + }; +// ... +} + +// Insert order using Dapr output binding via Dapr Client SDK +await client.InvokeBindingAsync(bindingName: sqlBindingName, operation: "exec", data: "", metadata: command); ``` ### Step 4: View the output of the job @@ -905,23 +909,38 @@ dapr run --app-id batch-sdk --app-port 6002 --dapr-http-port 3502 --dapr-grpc-po The code inside the `process_batch` function is executed every 10 seconds (defined in [`binding-cron.yaml`]({{< ref "#componentsbinding-cronyaml-component-file" >}}) in the `components` directory). The binding trigger looks for a route called via HTTP POST in your Flask application by the Dapr sidecar. ```go -func processCron(w http.ResponseWriter, r *http.Request) { - fileContent, err := os.Open("../../orders.json") -} + // Triggered by Dapr input binding + r.HandleFunc("/"+cronBindingName, processBatch).Methods("POST") ``` The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table. ```go -client, err := dapr.NewClient() - // ... -sqlCmd := fmt.Sprintf("insert into orders (orderid, customer, price) values (%d, '%s', %s);", order.OrderId, order.Customer, strconv.FormatFloat(order.Price, 'f', 2, 64)) -fmt.Println(sqlCmd) -in := &dapr.InvokeBindingRequest{ - Name: bindingName, - Operation: "exec", - Data: []byte(""), - Metadata: map[string]string{"sql": sqlCmd}, +func sqlOutput(order Order) (err error) { + + client, err := dapr.NewClient() + if err != nil { + return err + } + + ctx := context.Background() + + sqlCmd := fmt.Sprintf("insert into orders (orderid, customer, price) values (%d, '%s', %s);", order.OrderId, order.Customer, strconv.FormatFloat(order.Price, 'f', 2, 64)) + fmt.Println(sqlCmd) + + // Insert order using Dapr output binding via Dapr SDK + in := &dapr.InvokeBindingRequest{ + Name: sqlBindingName, + Operation: "exec", + Data: []byte(""), + Metadata: map[string]string{"sql": sqlCmd}, + } + err = client.InvokeOutputBinding(ctx, in) + if err != nil { + return err + } + + return nil } ```