Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .NET examples to cryptography building block #3928

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
09b790b
fix navbar for preview branch
hhunter-ms Sep 26, 2023
3ff53b2
upmerge to preview branch
hhunter-ms Oct 11, 2023
3055c7c
update workflow
hhunter-ms Oct 12, 2023
a2e6d2e
Merge pull request #3769 from hhunter-ms/fix_navbar_1.13
hhunter-ms Oct 12, 2023
5fc8039
Merge branch 'v1.13' into upmerge2_10-11
hhunter-ms Oct 12, 2023
af705f1
update website roote
hhunter-ms Oct 12, 2023
60bbfe7
Merge branch 'v1.13' into fix_navbar_1.13_2
hhunter-ms Oct 12, 2023
46abdf5
Merge pull request #3822 from hhunter-ms/fix_navbar_1.13_2
hhunter-ms Oct 12, 2023
f5dc7b5
Merge branch 'v1.13' into upmerge2_10-11
hhunter-ms Oct 12, 2023
47ac05a
Merge pull request #3817 from hhunter-ms/upmerge2_10-11
hhunter-ms Oct 12, 2023
1e105d0
try and fix navbar
hhunter-ms Oct 12, 2023
f1dbd11
Merge pull request #3823 from hhunter-ms/v1.13
hhunter-ms Oct 12, 2023
0dde1be
fix navbar
hhunter-ms Oct 12, 2023
b004f9c
Merge branch 'v1.13' of https://github.com/dapr/docs into v1.13
hhunter-ms Oct 12, 2023
eb596d3
Merge pull request #3825 from hhunter-ms/v1.13
hhunter-ms Oct 12, 2023
3a2f85e
Update config.toml (#3827)
greenie-msft Oct 12, 2023
3cc2f02
Remove website root WF (#3829)
greenie-msft Oct 16, 2023
661a1ed
Added example for retrieving bulk deserialized items matching PR #117…
WhitWaldo Oct 23, 2023
5adcac9
SNS/SQS contention
amimimor Nov 12, 2023
58570f1
added recommendation
amimimor Nov 13, 2023
6a9ccf4
suggested edits
amimimor Nov 14, 2023
81ce707
Merge branch 'v1.13' of https://github.com/dapr/docs into v1.13
hhunter-ms Nov 21, 2023
81f6762
upmerge
hhunter-ms Nov 21, 2023
2842655
Merge pull request #3863 from amimimor/v1.13
hhunter-ms Nov 21, 2023
0aec60c
Merge branch 'v1.13' into upmerge_11-21
msfussell Nov 21, 2023
869e908
Merge pull request #3879 from hhunter-ms/upmerge_11-21
hhunter-ms Nov 21, 2023
9be31d9
Update config.toml (#3882)
yaron2 Nov 22, 2023
02a84b0
Update config.toml (#3883)
yaron2 Nov 22, 2023
3114f4d
Adds Daprd `--block-shutdown-seconds` reference
JoshVanL Dec 4, 2023
22b7057
Updates block-shutdown-seconds to block-shutdown-duration
JoshVanL Dec 5, 2023
8c249b0
Merge branch 'v1.13' into block-shutdown-seconds
hhunter-ms Dec 8, 2023
2db304e
Update arguments-annotations-overview.md
JoshVanL Dec 8, 2023
477451e
Merge pull request #3893 from JoshVanL/block-shutdown-seconds
hhunter-ms Dec 8, 2023
a6f8ce3
last upmerge of 2023
hhunter-ms Dec 22, 2023
4af96d3
Merge pull request #3926 from hhunter-ms/upmerge_12-22
hhunter-ms Dec 22, 2023
52d796a
Merge branch 'dapr:v1.13' into v1.13
WhitWaldo Dec 23, 2023
bb11cf5
Added .NET examples to cryptography building block
WhitWaldo Dec 23, 2023
c19cd9d
Added .NET examples to cryptography building block
WhitWaldo Dec 23, 2023
f94b346
Merge branch 'cryptography-dotnet' of https://github.com/WhitWaldo/da…
WhitWaldo Jan 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions .github/workflows/website-root.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Azure Static Web App v1.12
name: Azure Static Web App v1.13

on:
push:
branches:
- v1.12
- v1.13
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- v1.12
- v1.13

jobs:
build_and_deploy_job:
Expand All @@ -28,7 +28,7 @@ jobs:
HUGO_ENV: production
HUGO_VERSION: "0.100.2"
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_V1_12 }}
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_V1_13 }}
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
skip_deploy_on_missing_secrets: true
action: "upload"
Expand All @@ -49,6 +49,6 @@ jobs:
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_V1_12 }}
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_V1_13 }}
skip_deploy_on_missing_secrets: true
action: "close"
10 changes: 5 additions & 5 deletions daprdocs/config.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Site Configuration
baseURL = "https://docs.dapr.io"
baseURL = "https://v1-13.docs.dapr.io"
title = "Dapr Docs"
theme = "docsy"
disableFastRender = true
Expand Down Expand Up @@ -183,17 +183,17 @@ github_subdir = "daprdocs"
github_branch = "v1.12"

# Versioning
version_menu = "v1.12 (latest)"
version = "v1.12"
version_menu = "v1.13 (preview)"
version = "v1.13"
archived_version = false
url_latest_version = "https://docs.dapr.io"

[[params.versions]]
version = "v1.13 (preview)"
url = "https://v1-13.docs.dapr.io"
url = "#"
[[params.versions]]
version = "v1.12 (latest)"
url = "#"
url = "https://docs.dapr.io"
[[params.versions]]
version = "v1.11"
url = "https://v1-11.docs.dapr.io"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Now that you've read about [Cryptography as a Dapr building block]({{< ref crypt

## Encrypt

{{< tabs "JavaScript" "Go" >}}
{{< tabs "JavaScript" "Go", "C#" >}}

{{% codetab %}}

Expand Down Expand Up @@ -136,6 +136,29 @@ if err != nil {

{{% /codetab %}}

{{% codetab %}}

<!-- C# -- >
Using the Dapr SDK in your project, you can encrypt data in an array of bytes. To encrypt a string, encode it first to an array of bytes with UTF-8 or another such encoding with `Encoding.UTF8.GetBytes(plainTextString)`.

```csharp
// When passing data, `encrypt` returns an array of bytes with the encrypted value
const string componentName = "azurekeyvault";
const string keyName = "myKey";

var encryptedBytes = await client.EncryptAsync(componentName, plainTextBytes, KeyWrapAlgorithm.Rsa, keyName, DataEncryptionCipher.AesGcm, cancellationToken);
```

The APIs can also be used with streams to encrypt the data more efficiently. The example below encrypts
a file using `FileStream` to an array of bytes:

```csharp
await using var fs = new FileStream("myfile.txt", FileMode.Open);
var encryptedBytes = await client.EncryptAsync(componentName, fs, KeyWrapAlgorithm.Rsa, keyName, DataEncryptionCipher.AesGcm, cancellationToken);
```

{{% /codetab %}}

{{< /tabs >}}


Expand Down Expand Up @@ -186,6 +209,25 @@ out, err := sdkClient.Decrypt(context.Background(), rf, dapr.EncryptOptions{

{{% /codetab %}}

{{% codetab %}}

<!-- C# -->

To decrypt a file, use the `DecryptAsync` method and pass it either a byte array or a stream.

```csharp
const string componentName = "azurekeyvault";
const string keyName = "myKey";

var decryptedBytes = await client.DecryptAsync(componentName, encryptedBytes, keyName, cancellationToken);

// `DecryptAsync` can also accept a stream like a `FileStream` or `MemoryStream`
await using var memoryStream = new MemoryStream(encryptedBytes);
var decryptedBytesFromStream = await client.DecryptAsync(componentName, memoryStream, keyName, cancellationToken);
```

{{% /codetab %}}

{{< /tabs >}}

## Next steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,33 @@ To launch a Dapr sidecar for the above example application, run a command simila
dapr run --app-id orderprocessing --app-port 6001 --dapr-http-port 3601 --dapr-grpc-port 60001 dotnet run
```

The above example will return a `BulkStateItem` with the serialized format of the value you saved to state. If you would prefer that the value be deserialized by the SDK across each of your bulk response items, you can instead use the following:

```csharp
//dependencies
using Dapr.Client;
//code
namespace EventService
{
class Program
{
static async Task Main(string[] args)
{
string DAPR_STORE_NAME = "statestore";
//Using Dapr SDK to retrieve multiple states
using var client = new DaprClientBuilder().Build();
IReadOnlyList<BulkStateItem<Widget>> mulitpleStateResult = await client.GetBulkStateAsync<Widget>(DAPR_STORE_NAME, new List<string> { "widget_1", "widget_2" }, parallelism: 1);
}
}

class Widget
{
string Size { get; set; }
string Color { get; set; }
}
}
```

{{% /codetab %}}

{{% codetab %}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ This table is meant to help users understand the equivalent options for running
| `--sentry-address` | `--sentry-address` | | not supported | Address for the [Sentry CA service]({{< ref sentry >}}) |
| `--version` | `--version` | `-v` | not supported | Prints the runtime version |
| `--dapr-graceful-shutdown-seconds` | not supported | | `dapr.io/graceful-shutdown-seconds` | Graceful shutdown duration in seconds for Dapr, the maximum duration before forced shutdown when waiting for all in-progress requests to complete. Defaults to `5`. If you are running in Kubernetes mode, this value should not be larger than the Kubernetes termination grace period, who's default value is `30`.|
| `--dapr-block-shutdown-duration` | not supported | | `dapr.io/block-shutdown-duration` | Block shutdown duration, if set, blocks the graceful shutdown procedure (as described above) from starting until the given duration has elapsed or the application becomes unhealthy as configured through application health options. This is useful for applications that need to execute Dapr APIs during their own termination procedure. Any new invocations of any Dapr APIs are not available to the application once the block has expired. Accepts [Go duration](https://pkg.go.dev/time#ParseDuration) string. |
| not supported | not supported | | `dapr.io/enabled` | Setting this paramater to true injects the Dapr sidecar into the pod |
| not supported | not supported | | `dapr.io/api-token-secret` | Tells Dapr which Kubernetes secret to use for [token-based API authentication]({{< ref api-token >}}). By default this is not set |
| not supported | not supported | | `dapr.io/app-token-secret` | Tells Dapr which Kubernetes secret to use for [token-based application authentication]({{< ref app-api-token >}}). By default, this is not set |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ aliases:

## Component format

To set up AWS SNS/SQS pub/sub, create a component of type `pubsub.aws.snssqs`.
To set up AWS SNS/SQS pub/sub, create a component of type `pubsub.aws.snssqs`.

By default, the AWS SNS/SQS component:

- Generates the SNS topics
- Provisions the SQS queues
- Configures a subscription of the queues to the topics

{{% alert title="Note" color="primary" %}}
If you only have a publisher and no subscriber, only the SNS topics are created.
If you only have a publisher and no subscriber, only the SNS topics are created.

However, if you have a subscriber, SNS, SQS, and the dynamic or static subscription thereof are generated.
{{% /alert %}}
Expand Down Expand Up @@ -133,6 +134,22 @@ When configuring the PubSub component with SQS dead-letter queues, the metadata
When running the Dapr sidecar (`daprd`) with your application on EKS (AWS Kubernetes) node/pod already attached to an IAM policy defining access to AWS resources, you **must not** provide AWS access-key, secret-key, and tokens in the definition of the component spec.
{{% /alert %}}

#### SNS/SQS Contention with Dapr

Fundamentally, SNS aggregates messages from multiple publisher topics into a single SQS queue by creating SQS subscriptions to those topics. As a subscriber, the SNS/SQS pub/sub component consumes messages from that sole SQS queue.

However, like any SQS consumer, the component cannot selectively retrieve the messages published to the SNS topics to which it is specifically subscribed. This can result in the component receiving messages originating from topics without associated handlers. Typically, this occurs during:

- **Component initialization:** If infrastructure subscriptions are ready before component subscription handlers, or
- **Shutdown:** If component handlers are removed before infrastructure subscriptions.

Since this issue affects any SQS consumer of multiple SNS topics, the component cannot prevent consuming messages from topics lacking handlers. When this happens, the component logs an error indicating such messages were erroneously retrieved.

In these situations, the unhandled messages would reappear in SQS with their [receive count](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html#sqs-receive-count) decremented after each pull. Thus, there is a risk that an unhandled message could exceed its `messageReceiveLimit` and be lost.

{{% alert title="Important" color="warning" %}}
Consider potential contention scenarios when using SNS/SQS with Dapr, and configure `messageReceiveLimit` appropriately. It is highly recommended to use SQS dead-letter queues by setting `sqsDeadLettersQueueName` to prevent losing messages.
{{% /alert %}}

## Create an SNS/SQS instance

Expand Down
Loading