From 48a87d27169415a8af3f3499e40cf72ec7dc96f0 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Thu, 15 Jun 2023 13:04:49 -0400 Subject: [PATCH 1/5] add pollingInterval Signed-off-by: Hannah Hunter --- .../components-reference/supported-bindings/storagequeues.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md index 5e0d89330bb..2cc4fc05033 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md @@ -27,6 +27,8 @@ spec: value: "***********" - name: queueName value: "myqueue" +# - name: pollingInterval +# value: "30s" # - name: ttlInSeconds # value: "60" # - name: decodeBase64 @@ -50,6 +52,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr | `accountName` | Y | Input/Output | The name of the Azure Storage account | `"account1"` | | `accountKey` | Y* | Input/Output | The access key of the Azure Storage account. Only required when not using Azure AD authentication. | `"access-key"` | | `queueName` | Y | Input/Output | The name of the Azure Storage queue | `"myqueue"` | +| `pollingInterval` | N | Output | Set the interval to poll Azure Storage Queues for new messages. Default: `"10s"` | `"30s"` | | `ttlInSeconds` | N | Output | Parameter to set the default message time to live. If this parameter is omitted, messages will expire after 10 minutes. See [also](#specifying-a-ttl-per-message) | `"60"` | | `decodeBase64` | N | Output | Configuration to decode base64 file content before saving to Storage Queues. (In case of saving a file with binary content). Defaults to `false` | `true`, `false` | | `encodeBase64` | N | Output | If enabled base64 encodes the data payload before uploading to Azure storage queues. Default `false`. | `true`, `false` | From 5a981e5d76d4c2f985cc8f8419b8ddab28619fe6 Mon Sep 17 00:00:00 2001 From: Hannah Hunter Date: Thu, 15 Jun 2023 14:50:52 -0400 Subject: [PATCH 2/5] update dapr publish command Signed-off-by: Hannah Hunter --- .../building-blocks/pubsub/pubsub-cloudevents.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-cloudevents.md b/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-cloudevents.md index 251d3f234c1..51d442f8a71 100644 --- a/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-cloudevents.md +++ b/daprdocs/content/en/developing-applications/building-blocks/pubsub/pubsub-cloudevents.md @@ -92,7 +92,7 @@ You can add additional fields to a custom CloudEvent that are not part of the of Publish a CloudEvent to the `orders` topic: ```bash -dapr publish --publish-app-id orderprocessing --pubsub order-pub-sub --topic orders --data '{"specversion" : "1.0", "type" : "com.dapr.cloudevent.sent", "source" : "testcloudeventspubsub", "subject" : "Cloud Events Test", "id" : "someCloudEventId", "time" : "2021-08-02T09:00:00Z", "datacontenttype" : "application/cloudevents+json", "data" : {"orderId": "100"}}' +dapr publish --publish-app-id orderprocessing --pubsub order-pub-sub --topic orders --data '{\"orderId\": \"100\"}' ``` {{% /codetab %}} From 01ac56cfd81c376d44110aaa857e80c2dc369b79 Mon Sep 17 00:00:00 2001 From: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Date: Thu, 15 Jun 2023 20:58:44 +0000 Subject: [PATCH 3/5] Update SQL Server docs for Azure AD Fixes #3344 Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- .../supported-state-stores/setup-sqlserver.md | 98 +++++++++++++------ 1 file changed, 66 insertions(+), 32 deletions(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-sqlserver.md b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-sqlserver.md index 4ef3c7dec80..e4f48d547b6 100644 --- a/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-sqlserver.md +++ b/daprdocs/content/en/reference/components-reference/supported-state-stores/setup-sqlserver.md @@ -2,14 +2,16 @@ type: docs title: "Microsoft SQL Server & Azure SQL" linkTitle: "Microsoft SQL Server & Azure SQL" -description: Detailed information on the Microsoft SQL Server and Azure SQL state store component +description: Detailed information on the Microsoft SQL Server state store component aliases: - "/operations/components/setup-state-store/supported-state-stores/setup-sqlserver/" --- ## Component format -To set up Microsoft SQL Server and Azure SQL state stores, create a component of type `state.sqlserver`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration. +This state store component can be used with both [Microsoft SQL Server](https://learn.microsoft.com/sql/) and [Azure SQL](https://learn.microsoft.com/azure/azure-sql/). + +To set up this state store, create a component of type `state.sqlserver`. See [this guide]({{< ref "howto-get-save-state.md#step-1-setup-a-state-store" >}}) on how to create and apply a state store configuration. ```yaml @@ -21,30 +23,42 @@ spec: type: state.sqlserver version: v1 metadata: - - name: connectionString - value: # Required. - - name: tableName - value: # Optional. defaults to "state" - - name: keyType - value: # Optional. defaults to "string" - - name: keyLength - value: # Optional. defaults to 200. You be used with "string" keyType - - name: schema - value: # Optional. defaults to "dbo" - - name: indexedProperties - value: # Optional. List of IndexedProperties. - - name: metadataTableName # Optional. Name of the table where to store metadata used by Dapr - value: "dapr_metadata" - - name: cleanupIntervalInSeconds # Optional. Cleanup interval in seconds, to remove expired rows - value: 300 - + # Authenticate using SQL Server credentials + - name: connectionString + value: | + Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword; + + # Authenticate with Azure AD (Azure SQL only) + # "useAzureAD" be set to "true" + - name: useAzureAD + value: true + # Connection string or URL of the Azure SQL database, optionally containing the database + - name: connectionString + value: | + sqlserver://myServerName.database.windows.net:1433?database=myDataBase + + # Other optional fields (listing default values) + - name: tableName + value: "state" + - name: metadataTableName + value: "dapr_metadata" + - name: schema + value: "dbo" + - name: keyType + value: "string" + - name: keyLength + value: "200" + - name: indexedProperties + value: "" + - name: cleanupIntervalInSeconds + value: "3600" ``` {{% alert title="Warning" color="warning" %}} The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}} -If you wish to use SQL server as an [actor state store]({{< ref "state_api.md#configuring-state-store-for-actors" >}}), append the following to the yaml. +If you wish to use SQL server as an [actor state store]({{< ref "state_api.md#configuring-state-store-for-actors" >}}), append the following to the metadata: ```yaml - name: actorStateStore @@ -53,24 +67,43 @@ If you wish to use SQL server as an [actor state store]({{< ref "state_api.md#co ## Spec metadata fields +### Authenticate using SQL Server credentials + +The following metadata options are **required** to authenticate using SQL Server credentials. This is supported on both SQL Server and Azure SQL. + +| Field | Required | Details | Example | +|--------|:--------:|---------|---------| +| `connectionString` | Y | The connection string used to connect.
If the connection string contains the database, it must already exist. Otherwise, if the database is omitted, a default database named "Dapr" is created. | `"Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;"` | + +### Authenticate using Azure AD + +Authenticating with Azure AD is supported with Azure SQL only. All authentication methods supported by Dapr can be used, including client credentials ("service principal") and Managed Identity. + +| Field | Required | Details | Example | +|--------|:--------:|---------|---------| +| `useAzureAD` | Y | Must be set to `true` to enable the component to retrieve access tokens from Azure AD. | `"true"` | +| `connectionString` | Y | The connection string or URL of the Azure SQL database, **without credentials**.
If the connection string contains the database, it must already exist. Otherwise, if the database is omitted, a default database named "Dapr" is created. | `"sqlserver://myServerName.database.windows.net:1433?database=myDataBase"` | +| `azureTenantId` | N | ID of the Azure AD tenant | `"cd4b2887-304c-47e1-b4d5-65447fdd542b"` | +| `azureClientId` | N | Client ID (application ID) | `"c7dd251f-811f-4ba2-a905-acd4d3f8f08b"` | +| `azureClientSecret` | N | Client secret (application password) | `"Ecy3XG7zVZK3/vl/a2NSB+a1zXLa8RnMum/IgD0E"` | + +### Other metadata options + | Field | Required | Details | Example | |--------------------|:--------:|---------|---------| -| connectionString | Y | The connection string used to connect. If the connection string contains the database it must already exist. If the database is omitted a default database named `"Dapr"` is created. | `"Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;Password=myPassword;"` -| tableName | N | The name of the table to use. Alpha-numeric with underscores. Defaults to `"state"` | `"table_name"` -| keyType | N | The type of key used. Defaults to `"string"` | `"string"` -| keyLength | N | The max length of key. Used along with `"string"` keytype. Defaults to `"200"` | `"200"` -| schema | N | The schema to use. Defaults to `"dbo"` | `"dapr"`,`"dbo"` -| indexedProperties | N | List of IndexedProperties. | `'[{"column": "transactionid", "property": "id", "type": "int"}, {"column": "customerid", "property": "customer", "type": "nvarchar(100)"}]'` -| actorStateStore | N | Indicates that Dapr should configure this component for the actor state store ([more information]({{< ref "state_api.md#configuring-state-store-for-actors" >}})). | `"true"` -| metadataTableName | N | Name of the table Dapr uses to store a few metadata properties. Defaults to `dapr_metadata`. | `"dapr_metadata"` -| cleanupIntervalInSeconds | N | Interval, in seconds, to clean up rows with an expired TTL. Default: `3600` (i.e. 1 hour). Setting this to values <=0 disables the periodic cleanup. | `1800`, `-1` +| `tableName` | N | The name of the table to use. Alpha-numeric with underscores. Defaults to `"state"` | `"table_name"` +| `metadataTableName` | N | Name of the table Dapr uses to store a few metadata properties. Defaults to `dapr_metadata`. | `"dapr_metadata"` +| `keyType` | N | The type of key used. Supported values: `"string"` (default), `"uuid"`, `"integer"`.| `"string"` +| `keyLength` | N | The max length of key. Ignored if "keyType" is not `string`. Defaults to `"200"` | `"200"` +| `schema` | N | The schema to use. Defaults to `"dbo"` | `"dapr"`,`"dbo"` +| `indexedProperties` | N | List of indexed properties, as a string containing a JSON document. | `'[{"column": "transactionid", "property": "id", "type": "int"}, {"column": "customerid", "property": "customer", "type": "nvarchar(100)"}]'` +| `actorStateStore` | N | Indicates that Dapr should configure this component for the actor state store ([more information]({{< ref "state_api.md#configuring-state-store-for-actors" >}})). | `"true"` +| `cleanupIntervalInSeconds` | N | Interval, in seconds, to clean up rows with an expired TTL. Default: `"3600"` (i.e. 1 hour). Setting this to values <=0 disables the periodic cleanup. | `"1800"`, `"-1"` ## Create a Microsoft SQL Server/Azure SQL instance -[Follow the instructions](https://docs.microsoft.com/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&tabs=azure-portal) from the Azure documentation on how to create a SQL database. The database must be created before Dapr consumes it. - -> Note: Microsoft SQL Server/Azure SQL state store also supports SQL Server running on VMs and in Docker.** +[Follow the instructions](https://docs.microsoft.com/azure/azure-sql/database/single-database-create-quickstart?view=azuresql&tabs=azure-portal) from the Azure documentation on how to create a SQL database. The database must be created before Dapr consumes it. In order to setup SQL Server as a state store, you need the following properties: @@ -104,6 +137,7 @@ CREATE CLUSTERED INDEX expiredate_idx ON state(ExpireDate ASC) ``` ## Related links + - [Basic schema for a Dapr component]({{< ref component-schema >}}) - Read [this guide]({{< ref "howto-get-save-state.md#step-2-save-and-retrieve-a-single-state" >}}) for instructions on configuring state store components - [State management building block]({{< ref state-management >}}) From ac7b88b34b5e8007aeec7ed5f7d44b5e1cf68e0e Mon Sep 17 00:00:00 2001 From: Mark Fussell Date: Thu, 15 Jun 2023 17:47:56 -0700 Subject: [PATCH 4/5] Update daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md Co-authored-by: Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> Signed-off-by: Mark Fussell --- .../components-reference/supported-bindings/storagequeues.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md index 2cc4fc05033..e3296660123 100644 --- a/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md +++ b/daprdocs/content/en/reference/components-reference/supported-bindings/storagequeues.md @@ -52,7 +52,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr | `accountName` | Y | Input/Output | The name of the Azure Storage account | `"account1"` | | `accountKey` | Y* | Input/Output | The access key of the Azure Storage account. Only required when not using Azure AD authentication. | `"access-key"` | | `queueName` | Y | Input/Output | The name of the Azure Storage queue | `"myqueue"` | -| `pollingInterval` | N | Output | Set the interval to poll Azure Storage Queues for new messages. Default: `"10s"` | `"30s"` | +| `pollingInterval` | N | Output | Set the interval to poll Azure Storage Queues for new messages, as a Go duration value. Default: `"10s"` | `"30s"` | | `ttlInSeconds` | N | Output | Parameter to set the default message time to live. If this parameter is omitted, messages will expire after 10 minutes. See [also](#specifying-a-ttl-per-message) | `"60"` | | `decodeBase64` | N | Output | Configuration to decode base64 file content before saving to Storage Queues. (In case of saving a file with binary content). Defaults to `false` | `true`, `false` | | `encodeBase64` | N | Output | If enabled base64 encodes the data payload before uploading to Azure storage queues. Default `false`. | `true`, `false` | From 377d8a5ae080cf61b6fee2042a1fbf7d66dd9025 Mon Sep 17 00:00:00 2001 From: Aaron Crawfis Date: Fri, 16 Jun 2023 16:23:27 -0700 Subject: [PATCH 5/5] Update code snippets to show button on hover (#3561) Signed-off-by: Aaron Crawfis --- daprdocs/assets/scss/_code.scss | 56 +++++++------------ daprdocs/static/js/copy-code-button.js | 74 +++++++++++--------------- 2 files changed, 48 insertions(+), 82 deletions(-) diff --git a/daprdocs/assets/scss/_code.scss b/daprdocs/assets/scss/_code.scss index dd05e51bf1b..49ad9c8b36a 100644 --- a/daprdocs/assets/scss/_code.scss +++ b/daprdocs/assets/scss/_code.scss @@ -1,38 +1,12 @@ // Code formatting. -.copy-code-button { - color: #272822; - background-color: #FFF; - border-color: #0D2192; - border: 2px solid; - border-radius: 3px 3px 0px 0px; - - /* right-align */ - display: block; - margin-left: auto; - margin-right: 0; - - margin-bottom: -2px; - padding: 3px 8px; - font-size: 0.8em; +.highlight .copy-icon { + position: absolute; + right: 20px; + top: 18px; + opacity: 0.7; } -.copy-code-button:hover { - cursor: pointer; - background-color: #F2F2F2; -} - -.copy-code-button:focus { - /* Avoid an ugly focus outline on click in Chrome, - but darken the button for accessibility. - See https://stackoverflow.com/a/25298082/1481479 */ - background-color: #E6E6E6; - outline: 0; -} - -.copy-code-button:active { - background-color: #D9D9D9; -} .highlight pre { /* Avoid pushing up the copy buttons. */ @@ -40,25 +14,31 @@ } .td-content { - // Highlighted code. + + // Highlighted code. .highlight { @extend .card; - + margin: 0rem 0; padding: 0rem; margin-bottom: 2rem; max-width: 100%; - + + border: none; + pre { margin: 0; padding: 1rem; + border-radius: 10px; } } // Inline code - p code, li > code, table code { + p code, + li>code, + table code { color: inherit; padding: 0.2em 0.4em; margin: 0; @@ -78,11 +58,11 @@ word-wrap: normal; background-color: $gray-100; padding: $spacer; - + max-width: 100%; - > code { - background-color: inherit !important; + >code { + background-color: inherit !important; padding: 0; margin: 0; font-size: 100%; diff --git a/daprdocs/static/js/copy-code-button.js b/daprdocs/static/js/copy-code-button.js index 579d2514824..ca5d0e26e90 100644 --- a/daprdocs/static/js/copy-code-button.js +++ b/daprdocs/static/js/copy-code-button.js @@ -1,49 +1,35 @@ -function addCopyButtons(clipboard) { - document.querySelectorAll('pre > code').forEach(function(codeBlock) { - var button = document.createElement('button'); - button.className = 'copy-code-button'; - button.type = 'button'; - button.innerText = 'Copy'; +const highlightClass = document.querySelectorAll('.highlight'); - button.addEventListener('click', function() { - clipboard.writeText(codeBlock.textContent).then( - function() { - button.blur(); +highlightClass.forEach(element => { + const copyIcon = document.createElement('i'); + copyIcon.classList.add('fas', 'fa-copy', 'copy-icon'); + copyIcon.style.color = 'white'; + copyIcon.style.display = 'none'; + element.appendChild(copyIcon); - button.innerText = 'Copied!'; - setTimeout(function() { - button.innerText = 'Copy'; - }, 2000); - }, - function(error) { - button.innerText = 'Error'; - console.error(error); - } - ); - }); + element.addEventListener('mouseenter', () => { + copyIcon.style.display = 'inline'; + }); - var pre = codeBlock.parentNode; - if (pre.parentNode.classList.contains('highlight')) { - var highlight = pre.parentNode; - highlight.parentNode.insertBefore(button, highlight); - } else { - pre.parentNode.insertBefore(button, pre); - } - }); -} + element.addEventListener('mouseleave', () => { + copyIcon.style.display = 'none'; + copyIcon.classList.replace('fa-check', 'fa-copy'); + }); -if (navigator && navigator.clipboard) { - addCopyButtons(navigator.clipboard); -} else { - var script = document.createElement('script'); - script.src = - 'https://cdnjs.cloudflare.com/ajax/libs/clipboard-polyfill/2.7.0/clipboard-polyfill.promise.js'; - script.integrity = 'sha256-waClS2re9NUbXRsryKoof+F9qc1gjjIhc2eT7ZbIv94='; - script.crossOrigin = 'anonymous'; + copyIcon.addEventListener('click', async () => { + const selection = window.getSelection(); + const range = document.createRange(); + range.selectNodeContents(element); + selection.removeAllRanges(); + selection.addRange(range); - script.onload = function() { - addCopyButtons(clipboard); - }; - - document.body.appendChild(script); -} + try { + await navigator.clipboard.writeText(selection.toString()); + console.log('Text copied to clipboard'); + copyIcon.classList.replace('fa-copy', 'fa-check'); + selection.removeAllRanges(); + } catch (error) { + console.error('Failed to copy: ', error); + } + }); +});