mirror of https://github.com/dapr/docs.git
				
				
				
			Merge branch 'v1.12' into issue_3965_1.12
This commit is contained in:
		
						commit
						87c70c0bde
					
				| 
						 | 
				
			
			@ -3,10 +3,11 @@ type: docs
 | 
			
		|||
title: "Use the Dapr API"
 | 
			
		||||
linkTitle: "Use the Dapr API"
 | 
			
		||||
weight: 30
 | 
			
		||||
description: "Run a Dapr sidecar and try out the state API"
 | 
			
		||||
description: "Run a Dapr sidecar and try out the state management API"
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
In this guide, you'll simulate an application by running the sidecar and calling the API directly. After running Dapr using the Dapr CLI, you'll:
 | 
			
		||||
In this guide, you'll simulate an application by running the sidecar and calling the state management API directly. 
 | 
			
		||||
After running Dapr using the Dapr CLI, you'll:
 | 
			
		||||
 | 
			
		||||
- Save a state object.
 | 
			
		||||
- Read/get the state object.
 | 
			
		||||
| 
						 | 
				
			
			@ -21,7 +22,8 @@ In this guide, you'll simulate an application by running the sidecar and calling
 | 
			
		|||
 | 
			
		||||
### Step 1: Run the Dapr sidecar
 | 
			
		||||
 | 
			
		||||
The [`dapr run`]({{< ref dapr-run.md >}}) command launches an application, together with a sidecar.
 | 
			
		||||
The [`dapr run`]({{< ref dapr-run.md >}}) command normally runs your application and a Dapr sidecar. In this case, 
 | 
			
		||||
it only runs the sidecar since you are interacting with the state management API directly.
 | 
			
		||||
 | 
			
		||||
Launch a Dapr sidecar that will listen on port 3500 for a blank application named `myapp`:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,11 @@ You'll use the Dapr CLI as the main tool for various Dapr-related tasks. You can
 | 
			
		|||
 | 
			
		||||
The Dapr CLI works with both [self-hosted]({{< ref self-hosted >}}) and [Kubernetes]({{< ref Kubernetes >}}) environments.
 | 
			
		||||
 | 
			
		||||
{{% alert title="Before you begin" color="primary" %}}
 | 
			
		||||
In Docker Desktop's advanced options, verify you've allowed the default Docker socket to be used.
 | 
			
		||||
   <img src="/images/docker-desktop-setting.png" width=800 style="padding-bottom:15px;">
 | 
			
		||||
{{% /alert %}}
 | 
			
		||||
 | 
			
		||||
### Step 1: Install the Dapr CLI
 | 
			
		||||
 | 
			
		||||
{{< tabs Linux Windows MacOS Binaries>}}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -27,7 +27,7 @@ To initialize Dapr in your local or remote **Kubernetes** cluster for developmen
 | 
			
		|||
{{% /alert %}}
 | 
			
		||||
 | 
			
		||||
{{% alert title="Docker" color="primary" %}}
 | 
			
		||||
The recommended development environment requires [Docker](https://docs.docker.com/install/). While you can [initialize Dapr without a dependency on Docker]({{< ref self-hosted-no-docker.md >}})), the next steps in this guide assume the recommended Docker development environment.
 | 
			
		||||
The recommended development environment requires [Docker](https://docs.docker.com/install/). While you can [initialize Dapr without a dependency on Docker]({{< ref self-hosted-no-docker.md >}}), the next steps in this guide assume the recommended Docker development environment.
 | 
			
		||||
 | 
			
		||||
You can also install [Podman](https://podman.io/) in place of Docker. Read more about [initializing Dapr using Podman]({{< ref dapr-init.md >}}).
 | 
			
		||||
{{% /alert %}}
 | 
			
		||||
| 
						 | 
				
			
			@ -70,7 +70,7 @@ dapr init
 | 
			
		|||
 | 
			
		||||
**If you are installing on Mac OS Silicon with Docker,** you may need to perform the following workaround to enable `dapr init` to talk to Docker without using Kubernetes.
 | 
			
		||||
1. Navigate to **Docker Desktop** > **Settings** > **Advanced**.
 | 
			
		||||
1. Select the **Enable default Docker socket** checkbox.
 | 
			
		||||
1. Select the **Allow the default Docker socket to be used (requires password)** checkbox.
 | 
			
		||||
 | 
			
		||||
{{% /codetab %}}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -86,6 +86,7 @@ dapr init
 | 
			
		|||
 | 
			
		||||
{{< /tabs >}}
 | 
			
		||||
 | 
			
		||||
[See the troubleshooting guide if you encounter any error messages regarding Docker not being installed or running.]({{< ref "common_issues.md#dapr-cant-connect-to-docker-when-installing-the-dapr-cli" >}})
 | 
			
		||||
 | 
			
		||||
### Step 3: Verify Dapr version
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -88,7 +88,11 @@ kubectl rollout restart deployment/<deployment-name> --namespace <namespace-name
 | 
			
		|||
 | 
			
		||||
## Adding API token to client API invocations
 | 
			
		||||
 | 
			
		||||
Once token authentication is configured in Dapr, all clients invoking Dapr API will have to append the API token token to every request:
 | 
			
		||||
Once token authentication is configured in Dapr, all clients invoking Dapr API need to append the `dapr-api-token` token to every request. 
 | 
			
		||||
 | 
			
		||||
> **Note:** The Dapr SDKs read the [DAPR_API_TOKEN]({{< ref environment >}}) environment variable and set it for you by default.
 | 
			
		||||
 | 
			
		||||
<img src="/images/tokens-auth.png" width=800 style="padding-bottom:15px;">
 | 
			
		||||
 | 
			
		||||
### HTTP
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -89,11 +89,13 @@ kubectl rollout restart deployment/<deployment-name> --namespace <namespace-name
 | 
			
		|||
 | 
			
		||||
## Authenticating requests from Dapr
 | 
			
		||||
 | 
			
		||||
Once app token authentication is configured in Dapr, all requests *coming from Dapr* include the token.
 | 
			
		||||
Once app token authentication is configured using the environment variable or Kubernetes secret `app-api-token`, the Dapr sidecar always includes the HTTP header/gRPC metadata `dapr-api-token: <token>` in the calls to the app. From the app side, ensure you are authenticating using the `dapr-api-token` value which uses the `app-api-token` you set to authenticate requests from Dapr.
 | 
			
		||||
 | 
			
		||||
<img src="/images/tokens-auth.png" width=800 style="padding-bottom:15px;">
 | 
			
		||||
 | 
			
		||||
### HTTP
 | 
			
		||||
 | 
			
		||||
In case of HTTP, in your code look for the HTTP header `dapr-api-token` in incoming requests:
 | 
			
		||||
In your code, look for the HTTP header `dapr-api-token` in incoming requests:
 | 
			
		||||
 | 
			
		||||
```text
 | 
			
		||||
dapr-api-token: <token>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,6 +6,24 @@ weight: 1000
 | 
			
		|||
description: "Common issues and problems faced when running Dapr applications"
 | 
			
		||||
---
 | 
			
		||||
 | 
			
		||||
This guide covers common issues you may encounter while installing and running Dapr.
 | 
			
		||||
 | 
			
		||||
## Dapr can't connect to Docker when installing the Dapr CLI
 | 
			
		||||
 | 
			
		||||
When installing and initializing the Dapr CLI, if you see the following error message after running `dapr init`:
 | 
			
		||||
 | 
			
		||||
```bash
 | 
			
		||||
⌛  Making the jump to hyperspace...
 | 
			
		||||
❌  could not connect to docker. docker may not be installed or running
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Troubleshoot the error by ensuring:
 | 
			
		||||
 | 
			
		||||
1. [The correct containers are running.]({{< ref "install-dapr-selfhost.md#step-4-verify-containers-are-running" >}})
 | 
			
		||||
1. In Docker Desktop, verify the **Allow the default Docker socket to be used (requires password)** option is selected.
 | 
			
		||||
 | 
			
		||||
   <img src="/images/docker-desktop-setting.png" width=800 style="padding-bottom:15px;">
 | 
			
		||||
 | 
			
		||||
## I don't see the Dapr sidecar injected to my pod
 | 
			
		||||
 | 
			
		||||
There could be several reasons to why a sidecar will not be injected into a pod.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,8 +43,8 @@ The above example uses secrets as plain strings. It is recommended to use a secr
 | 
			
		|||
| redisUsername      | N        | Username for Redis host. Defaults to empty. Make sure your redis server version is 6 or above, and have created acl rule correctly. | `""`, `"default"`
 | 
			
		||||
| consumerID         | N        | The consumer group ID   | `"myGroup"`
 | 
			
		||||
| enableTLS          | N        | If the Redis instance supports TLS with public certificates, can be configured to be enabled or disabled. Defaults to `"false"` | `"true"`, `"false"`
 | 
			
		||||
| redeliverInterval  | N        | The interval between checking for pending messages to redelivery. Defaults to `"60s"`. `"0"` disables redelivery. | `"30s"`
 | 
			
		||||
| processingTimeout  | N        | The amount time a message must be pending before attempting to redeliver it. Defaults to `"15s"`. `"0"` disables redelivery. | `"30s"`
 | 
			
		||||
| redeliverInterval  | N        | The interval between checking for pending messages to redeliver. Can use either be Go duration string (for example "ms", "s", "m") or milliseconds number. Defaults to `"60s"`. `"0"` disables redelivery. | `"30s"`, `"5000"`
 | 
			
		||||
| processingTimeout  | N        | The amount time that a message must be pending before attempting to redeliver it. Can use either be Go duration string ( for example "ms", "s", "m") or milliseconds number. Defaults to `"15s"`. `"0"` disables redelivery. | `"60s"`, `"600000"`
 | 
			
		||||
| queueDepth         | N        | The size of the message queue for processing. Defaults to `"100"`. | `"1000"`
 | 
			
		||||
| concurrency        | N        | The number of concurrent workers that are processing messages. Defaults to `"10"`. | `"15"`
 | 
			
		||||
| redisType        | N        | The type of redis. There are two valid values, one is `"node"` for single node mode, the other is `"cluster"` for redis cluster mode. Defaults to `"node"`. | `"cluster"`
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 255 KiB  | 
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 24 KiB  | 
										
											Binary file not shown.
										
									
								
							
		Loading…
	
		Reference in New Issue