### SQL Server Connection String Example Source: https://docs.dapr.io/reference/cli/_print An example connection string for connecting to a SQL Server database, often used as a state store for Dapr. ```plaintext sqlserver://dapr:Pass@word@localhost:1433?database=dapr ``` -------------------------------- ### MongoDB Connection String Example Source: https://docs.dapr.io/reference/cli/_print An example connection string for connecting to a MongoDB database, often used as a state store for Dapr. ```plaintext mongodb://localhost:27017/dapr ``` -------------------------------- ### Start Dapr Workflow Instance CLI Command Source: https://docs.dapr.io/reference/cli/dapr-workflow Starts a new Dapr workflow instance with a specified workflow name and application ID. Optionally, input data can be provided for the workflow. ```bash dapr workflow run MyWorkflow --app-id myapp --input '{"key": "value"}' ``` -------------------------------- ### List Workflow Instances for Backup Source: https://docs.dapr.io/reference/cli/_print Example of using the 'dapr workflow list' command to export workflow instances to a JSON file for backup purposes before performing a bulk purge. This helps in data recovery if needed. ```bash dapr workflow list --app-id myapp --output json > backup.json ``` -------------------------------- ### Purge Specific Workflow Instance Source: https://docs.dapr.io/reference/cli/_print Example of purging a single workflow instance by its ID. Requires the workflow instance ID and the application ID. ```bash dapr workflow purge wf-12345 --app-id myapp ``` -------------------------------- ### Annotate Kubernetes Deployments with Dapr Source: https://docs.dapr.io/reference/cli/dapr-annotate These examples demonstrate how to use the 'dapr annotate' command with kubectl to add Dapr annotations to Kubernetes deployments. They cover annotating the first found deployment, multiple deployments by name, deployments in a specific namespace, and deployments from a URL. ```bash # Annotate the first deployment found in the input kubectl get deploy -l app=node -o yaml | dapr annotate -k - | kubectl apply -f - ``` ```bash # Annotate multiple deployments by name in a chain kubectl get deploy -o yaml | dapr annotate -k -r nodeapp - | dapr annotate -k -r pythonapp - | kubectl apply -f - ``` ```bash # Annotate deployment in a specific namespace from file or directory by name dapr annotate -k -r nodeapp -n namespace mydeploy.yaml | kubectl apply -f - ``` ```bash # Annotate deployment from url by name dapr annotate -k -r nodeapp --log-level debug https://raw.githubusercontent.com/dapr/quickstarts/master/tutorials/hello-kubernetes/deploy/node.yaml | kubectl apply -f - ``` -------------------------------- ### Purge Workflows in Kubernetes with Database Access Source: https://docs.dapr.io/reference/cli/_print Example of purging old workflow instances in a Kubernetes environment, including specifying connection details for a state store like PostgreSQL. This involves port-forwarding to the database and then executing the purge command with Kubernetes-specific flags. ```bash # Port forward to database kubectl port-forward service/postgres 5432:5432 -n production # Purge old workflows dapr workflow purge \ --kubernetes \ --namespace production \ --app-id myapp \ --connection-string "host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable" \ --table-name workflows \ --all-older-than 2160h # 90 days ``` -------------------------------- ### Purge All Terminal Workflow Instances Source: https://docs.dapr.io/reference/cli/_print Example of purging all workflow instances that have reached a terminal state (COMPLETED, FAILED, TERMINATED). This is a dangerous operation and should be used with extreme caution. Requires the application ID. ```bash dapr workflow purge --app-id myapp --all ``` -------------------------------- ### Purge Workflow Instances Older Than Timestamp Source: https://docs.dapr.io/reference/cli/_print Example of purging all terminal workflow instances that are older than a specific timestamp. Requires the application ID. ```bash dapr workflow purge --app-id myapp --all-older-than 2023-12-01T00:00:00Z ``` -------------------------------- ### Cron Job for Periodic Workflow Purge Source: https://docs.dapr.io/reference/cli/_print Example of a cron job configuration to automatically purge workflow instances older than 90 days. This demonstrates how to schedule regular cleanup operations. ```cron 0 2 * * 0 dapr workflow purge --app-id myapp --all-older-than 2160h ``` -------------------------------- ### Purge Workflow Instances Older Than Duration Source: https://docs.dapr.io/reference/cli/_print Example of purging all terminal workflow instances that are older than a specified duration (e.g., 720 hours which is 30 days). Requires the application ID. ```bash dapr workflow purge --app-id myapp --all-older-than 720h ``` -------------------------------- ### Dapr CLI Annotate Command Usage Source: https://docs.dapr.io/reference/cli/dapr-annotate This snippet shows the basic usage of the 'dapr annotate' command. It takes a configuration file as input and applies Dapr annotations based on the provided flags. The `--kubernetes` flag is required for Kubernetes resources. ```bash dapr annotate [flags] CONFIG-FILE ``` -------------------------------- ### List Dapr Workflow Instances CLI Command Source: https://docs.dapr.io/reference/cli/dapr-workflow Lists Dapr workflow instances for a given application ID. Supports filtering by status, name, and age, and can output in various formats. It also includes options for Kubernetes environments and direct database access. ```bash dapr workflow list --app-id myapp dapr workflow list --app-id myapp --filter-status RUNNING dapr workflow list --app-id myapp --filter-name OrderProcessing dapr workflow list --app-id myapp --filter-max-age 24h dapr workflow list --app-id myapp --filter-max-age 2024-01-01T00:00:00Z dapr workflow list --app-id myapp --output json dapr workflow list \ --kubernetes \ --namespace production \ --app-id myapp \ --connection-string "host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable" \ --table-name workflows ``` -------------------------------- ### dapr mtls Source: https://docs.dapr.io/reference/cli/dapr-mtls/_print Check if mTLS is enabled, or list available subcommands for managing mTLS certificates. ```APIDOC ## GET /dapr/mtls ### Description Check if mTLS is enabled in a Kubernetes cluster or list available subcommands for managing mTLS certificates. ### Method GET ### Endpoint /dapr/mtls ### Query Parameters - **-k, --kubernetes** (boolean) - Optional - Check if mTLS is enabled in a Kubernetes cluster. ### Request Example ``` dapr mtls -k ``` ### Response #### Success Response (200) - **status** (string) - Indicates whether mTLS is enabled or provides a list of commands. #### Response Example ```json { "status": "mTLS is enabled on the Kubernetes cluster." } ``` ``` -------------------------------- ### Dapr Workflow CLI Connection String Formats Source: https://docs.dapr.io/reference/cli/dapr-workflow Provides connection string formats for various database backends used with Dapr workflows, including PostgreSQL, MySQL, SQL Server, MongoDB, and Redis. ```text host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable dapr:dapr@tcp(localhost:3306)/dapr?parseTime=true sqlserver://dapr:Pass@word@localhost:1433?database=dapr mongodb://localhost:27017/dapr redis[s]://[[username][:password]@][host][:port][/db-number] ``` -------------------------------- ### dapr mtls export Source: https://docs.dapr.io/reference/cli/dapr-mtls/_print Export the root Certificate Authority (CA), issuer cert, and issuer key to local files. ```APIDOC ## GET /dapr/mtls/export ### Description Export the root Certificate Authority (CA), issuer cert and issuer key to local files. ### Method GET ### Endpoint /dapr/mtls/export ### Query Parameters - **-o, --out** (string) - Optional - The output directory path to save the certs. Defaults to the current directory. ### Request Example ``` dapr mtls export -o ./certs ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the export was successful. #### Response Example ```json { "message": "Certificates exported successfully to ./certs." } ``` ``` -------------------------------- ### Redis Connection String Pattern Source: https://docs.dapr.io/reference/cli/_print A pattern representing a connection string for Redis, which can be used as a state store for Dapr. It supports optional authentication and database selection. ```plaintext redis[s]://[[username][:password]@][host][:port][/db-number]: ``` -------------------------------- ### Dapr Workflow Purge Command Usage Source: https://docs.dapr.io/reference/cli/_print The basic usage of the Dapr CLI command to purge workflow instances. This command requires an app ID and can optionally take an instance ID or flags to specify which instances to purge. ```bash dapr workflow purge [instance-id] [flags] ``` -------------------------------- ### Purge Dapr Workflow Instances CLI Command Source: https://docs.dapr.io/reference/cli/dapr-workflow Purges Dapr workflow instances based on specific criteria. Can purge a single instance by ID, all instances older than a specified time, or all terminal instances. Supports Kubernetes and direct database access. ```bash dapr workflow purge wf-12345 --app-id myapp dapr workflow purge --app-id myapp --all-older-than 720h dapr workflow purge --app-id myapp --all-older-than 2023-12-01T00:00:00Z dapr workflow purge --app-id myapp --all dapr workflow purge \ --kubernetes \ --namespace production \ --app-id myapp \ --connection-string "host=localhost user=dapr password=dapr dbname=dapr port=5432 sslmode=disable" \ --table-name workflows ``` -------------------------------- ### dapr mtls expiry Source: https://docs.dapr.io/reference/cli/dapr-mtls/_print Check the expiry of the root Certificate Authority (CA) certificate. ```APIDOC ## GET /dapr/mtls/expiry ### Description Checks the expiry of the root Certificate Authority (CA) certificate. ### Method GET ### Endpoint /dapr/mtls/expiry ### Request Example ``` dapr mtls expiry ``` ### Response #### Success Response (200) - **expiry_days** (integer) - The number of days until the root CA certificate expires. - **expiry_date** (string) - The date and time of certificate expiry in UTC. #### Response Example ```json { "expiry_days": 180, "expiry_date": "2024-12-31T23:59:59Z" } ``` ``` -------------------------------- ### mtls renew-certificate CLI Command Source: https://docs.dapr.io/reference/cli/dapr-mtls/dapr-mtls-renew-certificate This command can be used to renew expiring Dapr certificates. It supports Kubernetes platforms and offers various flags to customize certificate generation and control plane restarts. ```APIDOC ## `dapr mtls renew-certificate` Command ### Description This command renews expiring Dapr certificates. It is particularly useful for managing Dapr's mTLS certificates in Kubernetes environments. ### Usage ```bash dapr mtls renew-certificate [flags] ``` ### Flags - `--help`, `-h` (bool): Help for the renew-certificate command. - `--kubernetes`, `-k` (bool): Supported platform. Default: `false`. - `--valid-until` (string): Validity for newly created certificates. Default: `365 days`. - `--restart` (bool): Restarts Dapr control plane services (Sentry, Operator, Placement). Default: `false`. - `--timeout` (string): The timeout for the certificate renewal process. Default: `300 sec`. - `--ca-root-certificate` (string): File path to user-provided PEM root certificate. - `--issuer-public-certificate` (string): File path to user-provided PEM issuer certificate. - `--issuer-private-key` (string): File path to user-provided PEM issuer private key. - `--private-key` (string): User-provided root.key file used to generate the root certificate. ### Examples #### Renew certificates by generating brand new certificates * **Generate new certificates for Kubernetes cluster (default 365 days validity, no control plane restart):** ```bash dapr mtls renew-certificate -k ``` * **Generate new certificates and restart control plane services:** ```bash dapr mtls renew-certificate -k --restart ``` * **Generate new certificates with a specific validity time:** ```bash dapr mtls renew-certificate -k --valid-until ``` * **Generate new certificates with specific validity and restart services:** ```bash dapr mtls renew-certificate -k --valid-until --restart ``` #### Renew certificate by using user-provided certificates * **Rotate certificates using provided CA, issuer cert, and issuer key, then restart services:** ```bash dapr mtls renew-certificate -k --ca-root-certificate --issuer-private-key --issuer-public-certificate --restart ``` * **Rotate certificates using provided CA, issuer cert, and issuer key (no restart):** ```bash dapr mtls renew-certificate -k --ca-root-certificate --issuer-private-key --issuer-public-certificate ``` #### Renew certificates by generating brand new certificates using the provided root private key * **Use existing private root.key to generate new certificates with specified validity:** ```bash dapr mtls renew-certificate -k --private-key myprivatekey.key --valid-until ``` * **Use existing private root.key to generate new certificates:** ```bash dapr mtls renew-certificate -k --private-key myprivatekey.key ``` ``` -------------------------------- ### dapr workflow purge Source: https://docs.dapr.io/reference/cli/_print Purges workflow instances that have reached a terminal state (COMPLETED, FAILED, TERMINATED). You can purge specific instances, instances older than a specified time, or all terminal instances. ```APIDOC ## POST /dapr/workflow/purge ### Description This endpoint purges workflow instances with terminal states. It supports purging specific instances, instances older than a specified duration or timestamp, or all terminal instances. ### Method POST ### Endpoint /dapr/workflow/purge ### Parameters #### Query Parameters - **--instance-id** (string) - Optional - The ID of the workflow instance to purge. - **--app-id** (string) - Required - The app ID owner of the workflow instances. - **--all** (bool) - Optional - Purge all terminal workflow instances. Use with caution. - **--all-older-than** (string) - Optional - Purge instances older than the specified duration (e.g., "24h") or timestamp (e.g., "2023-01-02T15:04:05Z"). - **--connection-string** (string) - Optional - Connection string to the actor state store. - **--table-name** (string) - Optional - Table or collection name used as the actor state store. - **--kubernetes** (bool) - Optional - Target a Kubernetes Dapr installation. - **--namespace** (string) - Optional - Kubernetes namespace (default "default"). ### Request Example ```json { "command": "dapr workflow purge --app-id myapp --all-older-than 720h" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the purge operation was successful. #### Response Example ```json { "message": "Workflow instances purged successfully." } ``` ``` -------------------------------- ### dapr mtls renew-certificate Source: https://docs.dapr.io/reference/cli/dapr-mtls/_print Renew expiring Dapr certificates, including the root and issuer certificates. ```APIDOC ## POST /dapr/mtls/renew-certificate ### Description Renews expiring Dapr certificates. This command can rotate the existing root and issuer certificates and restart Dapr control plane services. ### Method POST ### Endpoint /dapr/mtls/renew-certificate ### Query Parameters - **-k, --kubernetes** (boolean) - Optional - Specifies the platform as Kubernetes. - **--valid-until** (string) - Optional - Validity period for newly created certificates. Defaults to 365 days. - **--restart** (boolean) - Optional - Restarts Dapr control plane services (Sentry service, Operator service, and Placement server). Defaults to false. - **--timeout** (string) - Optional - The timeout for the certificate renewal process. Defaults to 300 sec. ### Request Body - **ca_root_certificate** (string) - Optional - File path to user-provided PEM root certificate. - **issuer_public_certificate** (string) - Optional - File path to user-provided PEM issuer certificate. - **issuer_private_key** (string) - Optional - File path to user-provided PEM issuer private key. - **private_key** (string) - Optional - User-provided root.key file used to generate the root certificate. ### Request Example ```json { "ca_root_certificate": "/path/to/ca.crt", "issuer_public_certificate": "/path/to/issuer.crt", "issuer_private_key": "/path/to/issuer.key", "private_key": "/path/to/root.key" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the certificate renewal process has started or completed. #### Response Example ```json { "message": "Certificate renewal process initiated successfully." } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.