Giter Site home page Giter Site logo

dapr / samples Goto Github PK

View Code? Open in Web Editor NEW
410.0 24.0 172.0 23.86 MB

Community driven repository for Dapr samples

License: Apache License 2.0

C# 14.17% JavaScript 24.78% Shell 8.24% Dockerfile 3.03% Go 4.02% CSS 3.23% HTML 2.51% PowerShell 11.02% Python 11.33% Makefile 4.56% TypeScript 0.86% Java 10.04% Bicep 2.22%
dapr pubsub events state binding service

samples's Introduction

Dapr Samples

Note: The Dapr samples have been recently reorganized. Samples that are aimed for newcomers and are meant to help users get started quickly with Dapr have been migrated to a separate repository dapr/quickstarts.

Samples in this repository showcase Dapr capabilities using different languages and address wide array of common scenarios. Some focus on specific usage patterns or particular Dapr capability while others are end-to-end demos leveraging several Dapr building blocks and capabilities.

If you are new to Dapr, you may want to review following resources first:

Note, these samples are maintained by the Dapr community and are not guaranteed to work properly with the latest Dapr runtime version.

Samples in this repository

Sample Details
Twitter Sentiment Processor Code sample used to demo Dapr during Microsoft's Build 2020 conference showing a polyglot distributed application which performs sentiment processing for tweets
Hello world slim (no Docker dependency) This sample is a version of the hello-world quickstart sample showing how to install initialize and use Dapr without having Docker in your local environment
Hello TypeScript This sample is a version of the hello-world quickstart sample showing how to use Dapr in a TypeScript project.
Docker compose sample Demonstrates how to get Dapr running locally with Docker Compose
Dapr, Azure Functions, and KEDA Shows Dapr being used with Azure Functions and KEDA to create a polygot Functions-as-a-Service application which leverages Dapr pub/sub
Middleware OAuth to Google APIs - Interactive Demonstrates use of Dapr middleware to enable OAuth 2.0 authorization and inject client secrets for Google APIs.
Middleware OAuth to Microsoft and AAD APIs - Non Interactive Demonstrates use of Dapr middleware to enable OAuth 2.0 authorization and inject client secrets for Microsoft and Azure Active Directory apps.
Read Kubernetes Events Shows Dapr being used with the Kubernetes Input binding to watch for events in Kubernetes cluster
Batch File Processing This sample demonstrates an end-to-end sample for processing a batch of related text files using microservices and Dapr. Through this sample you will learn about Dapr's state management, bindings, Pub/Sub, and end-to-end tracing.
Dapr integration in Azure APIM Dapr configuration in Azure API Management service using self-hosted gateway on Kubernetes. Illustrates exposing Dapr API for service method invocation, publishing content to a Pub/Sub topic, and binding invocation with request content transformation.
Distributed Calendar Shows use of statestore, pubsub and output binding features of Dapr to roughly create a distributed version of a MVCS architecture application.
Hello Service Fabric Shows use of statestore, pubsub and service invocation in a Service Fabric environment running the Dapr sidecar as a guest executable.
Pub-sub routing Demonstrates how to use Dapr to enable pub-sub applications with message routing.
Distributed Calculator with Knative Serving Demonstrates how to use Dapr and Knative Serving using distributed calculator from quickstarts.
commercetools GraphQL sample output binding Connects to commercetools, allowing you to query or manipulate a commercetools projects using a provided GraphlQL query.
WebAssembly Middleware Demonstrates how to serve HTTP responses directly from the dapr sidecar using WebAssembly.
Workflow + external endpoint invocation Demonstrates how to use the Dapr Workflow API to coordinate an order process that includes an activity which uses service invocation for non-Dapr endpoints.
Workflow + multi-app microservice in Python Demonstrates how to use the Dapr Workflow Python SDK to coordinate an order process across multiple dapr-enabled microservices.
Outbox in .NET Demonstrates how to use the outbox transactions with Redis and MySql statestores and Redis as the message broker

External samples

Sample Details
Dapr RetroPOS Dapr Retro Point of Sales is a sample of backend workflow based on microservices.
Dapr Traffic Control Simulated traffic-control system with speeding cameras. This sample features all the Dapr building-blocks. This is also the sample application used in the book Dapr for .NET Developers.
Dapr Examples Example usage of Dapr in Golang. This repository contains examples about to use of state store, access management, pubsub and subscription.
Java Pub/Sub Sample Demonstrate a pub/sub messaging architecture using Dapr for a Java application running in a Kubernetes cluster.
eShop on Dapr A sample .NET Core E-Commerce application based on eShopOnContainers, powered by Dapr.

Sample maintenance

Each sample includes README.md which provides information about the validated versions of Dapr for that sample.

If you would like to have a sample updated or better yet, update it yourself to a newer version of Dapr, please see the contribution guide to learn more about opening issues and submitting pull requests to this repository.

Note, over time, for maintainability reasons, some samples may be removed from this repository.

Sample contribution

If you want to contribute a sample to this repo, please see the sample contribution guide for details on the PR process.

Samples should follow these high-level guiding principles:

  • Sample should have a meaningful name that helps users understand what this sample is about
  • Sample code should be complete (i.e. no major code additions should be needed to make the sample work)
  • Each sample should include a README.md file clearly explaining what the sample does and how to run it including prerequisites. This file should also include details on the Dapr core version this sample is compatible with (see below).
  • Highly recommended:
    • architecture diagrams of the sample application
    • scripts and automation to allow users to easily run samples which require complex setup and multiple steps to run

Along with the sample code and README, samples should be listed in this page in the above samples table

Sample info section at the top of the main sample README should follow the following template:

Attribute Details
Dapr runtime version vX.X
Language [Languages used in the sample code]
Environment [Environment name]

Note: If you are not sure what Dapr runtime version you are running, use the Dapr CLI command dapr --version

Example:

Attribute Details
Dapr runtime version v1.12.0
Language Go, C# (.NET Core), Node.js
Environment Local or Kubernetes

Code of Conduct

Please refer to our Dapr Community Code of Conduct

samples's People

Contributors

aaroncrawfis avatar artursouza avatar brunoborges avatar cgillum avatar codefromthecrypt avatar darquewarrior avatar dependabot[bot] avatar edwinvw avatar greenie-msft avatar harrykimpel avatar marcduiker avatar mcandeia avatar mchmarny avatar msfussell avatar mukundansundar avatar my-petrichor avatar paulyuk avatar pkedy avatar pravinpushkar avatar robece avatar ross-p-smith avatar shchauh avatar shubham1172 avatar taction avatar tcnghia avatar tenst avatar willtsai avatar willvelida avatar yaron2 avatar youngbupark avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

samples's Issues

Compose: Some questions on running Hello Docker Compose.

Still trying to understand this:

Q) The Node app exposes port 3000, but here we map 50002 to 50002, why and what if multiple ports are exposed by service?
nodeapp:
build: ./node
ports:
- "50002:50002"

Q) a single -app-port, what if the container exposes multiple ports, 80, 443?
nodeapp-dapr:
image: "daprio/daprd:edge"
command: ["./daprd",
"-app-id", "nodeapp",
"-app-port", "3000",

Q)
Do I need to stop the default containers that Dapr Init creates ?

Q)
Is the placement service only necessary when using actors ?

Q)
Will these services display with dashboard and zipking ?
If so how do I access them ? the default urls are not displaying the services.

thx... :-)

Java Sample using DAPR on AKS

Hi there, we carried out some upskilling in Dapr for a project using Java Microservices architecture and wondered if it was a good fit to live under your samples? Happy to have a chat as we have a few weeks of wrapping up our project that we could lean in and shape the sample

You can have a look at it here: - https://github.com/mahmutcanga/java-banking-pubsub-dapr-sample

We are also thinking about putting this in Azure Samples - but would love a reach out!

Transactional outbox messages not being published in Outbox sample

In what area(s)?

/area runtime

/area operator

/area placement

/area docs

/area test-and-release

What version of Dapr?

Sample is on 1.12.0, but I have also reproduced the behavior in 1.13.5

Expected Behavior

I was interested in trying out the Transactional Outbox feature which is currently in preview along with Azure Cosmos DB and Azure Service Bus. I downloaded the sample application for Transactional Outbox and made a couple modifications to use Cosmos and Service Bus instead, which I've detailed in the "Steps to Reproduce the Problem" section below. Since Cosmos DB supports Transactions, I was under the impression this should work out of the box.

The expected behavior is that, after the sample makes a state transaction, a message should be published to the configured outboxPublishPubsub and outboxPublishTopic given by the state component.

Actual Behavior

The actual behavior is that no messages are sent.

If I look in Azure Service Bus, I can see that defaultorder-processorordersoutbox, defaultorder-processorordersoutbox, and orders topics are created, but none of those topics have any messages published to them.

Steps to Reproduce the Problem

  1. Clone the sample application for Transactional Outbox and replace the following resource files with the given snippets:

resources/pubsub.yaml:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: orderpubsub
spec:
  type: pubsub.azure.servicebus.topics
  version: v1
  metadata:
  - name: connectionString
    value: <CONNECTION-STRING>

resources/statestore.yaml:

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: statestore
spec:
  type: state.azure.cosmosdb
  version: v1
  metadata:
    - name: url
      value: <COSMOS-URL>
    - name: masterKey
      value: <COSMOS-MASTER-KEY>
    - name: database
      value: Orders
    - name: collection
      value: Items
    - name: outboxPublishPubsub
      value: orderpubsub
    - name: outboxPublishTopic
      value: orders

(Everything else is unmodified.)

  1. Run the applications using dapr run -f . as indicated in the instructions.

  2. Observe that the messages that are supposed to be published as a result of the state transaction are not actually published.

I have also tried replacing those with the SQLite storage component and the In-Memory pubsub component, and both of those appear to exhibit the same issue.

Release Note

RELEASE NOTE:

Compose: hello-docker-compose Explanation Questions

While this example works, it left me with a few questions.

1. Why is the node app grpc port exposed to the host computer?
2. Why does the node app depend on placement?
3. The app-id is the same as the name of the service, is that important/required?

dapr-apim-integration sample: echo-service and event-subscriber need a tracing config and fail to start

echo-service and event-subscriber have the annotation:

dapr.io/config: "tracing"

and fail to start as they can't find this config.

Fix:

  • Create a tracing config in file k8s/tracing.config.yaml:
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: tracing
  namespace: default
spec:
  tracing:
    samplingRate: "1"
    zipkin:
      endpointAddress: "http://zipkin.default.svc.cluster.local:9411/api/v2/spans"
kubectl apply -f k8s/tracing.config.yaml

Install Zipkin:

kubectl create deployment zipkin --image openzipkin/zipkin
kubectl expose deployment zipkin --type ClusterIP --port 9411

Redeploy echo-service and event-subscriber.

My environment:

  • Dapr 1.5.1
  • Kubernetes: v1.21.2

Issue relating to repository middleware-oauth-google

Hi Team, @paulyuk

relating to repository middleware-oauth-google,
As per echoapp.yaml file, its searching for image from repository location image: dapriosamples/middleware-echoapp:latest.

Let me know if we need to push image to this repo or its already exist in it?
Do we need to pass imagepullsecrets etc so that image can be available to read?

Currently for me http://dummy.com/v1.0/invoke/echoapp/method/echo?text=hello link is not connecting.

"couldn't find trust anchors in environment variable DAPR_TRUST_ANCHORS" in hello-docker-compose example

When I try to run this example, I get the msg "couldn't find trust anchors in environment variable DAPR_TRUST_ANCHORS".
I just change the port of node app and related config in Dockerfile and docker-compose.

Here is the full output:
$ hello-docker-compose > docker-compose up
Starting hello-docker-compose_placement_1 ... done
Starting hello-docker-compose_redis_1 ... done
Starting hello-docker-compose_pythonapp_1 ... done
Recreating hello-docker-compose_nodeapp_1 ... done
Starting hello-docker-compose_pythonapp-dapr_1 ... done
Recreating hello-docker-compose_nodeapp-dapr_1 ... done
Attaching to hello-docker-compose_redis_1, hello-docker-compose_placement_1, hello-docker-compose_pythonapp_1, hello-docker-compose_pythonapp-dapr_1, hello-docker-compose_nodeapp_1, hello-docker-compose_nodeapp-dapr_1
nodeapp_1 | Node App listening on port 7500!
placement_1 | time="2021-08-24T09:03:26.130927792Z" level=info msg="starting Dapr Placement Service -- version 1.3.0 -- commit 4bab7576ed68a9ece1a4743a7925f18ef583775a" instance=3f2415963b28 scope=dapr.placement type=log ver=unknown
placement_1 | time="2021-08-24T09:03:26.131061238Z" level=info msg="log level set to: info" instance=3f2415963b28 scope=dapr.placement type=log ver=1.3.0
placement_1 | time="2021-08-24T09:03:26.131151741Z" level=info msg="metrics server started on :9090/" instance=3f2415963b28 scope=dapr.metrics type=log ver=1.3.0
placement_1 | time="2021-08-24T09:03:26.131524408Z" level=info msg="Raft server is starting on 127.0.0.1:8201..." instance=3f2415963b28 scope=dapr.placement.raft type=log ver=1.3.0
placement_1 | time="2021-08-24T09:03:26.131556461Z" level=info msg="placement service started on port 50006" instance=3f2415963b28 scope=dapr.placement type=log ver=1.3.0
pythonapp-dapr_1 | time="2021-08-24T09:03:27.041031503Z" level=info msg="starting Dapr Runtime -- version edge -- commit 1f9adeed5be68005070ed85b63b52ee41331d4bc" app_id=pythonapp instance=636e33cae739 scope=dapr.runtime type=log ver=edge
pythonapp-dapr_1 | time="2021-08-24T09:03:27.041093688Z" level=info msg="log level set to: info" app_id=pythonapp instance=636e33cae739 scope=dapr.runtime type=log ver=edge
placement_1 | time="2021-08-24T09:03:26.131771597Z" level=info msg="Healthz server is listening on :8080" instance=3f2415963b28 scope=dapr.placement type=log ver=1.3.0
pythonapp-dapr_1 | time="2021-08-24T09:03:27.041247478Z" level=info msg="metrics server started on :9090/" app_id=pythonapp instance=636e33cae739 scope=dapr.metrics type=log ver=edge
placement_1 | time="2021-08-24T09:03:27.159422221Z" level=info msg="cluster leadership acquired" instance=3f2415963b28 scope=dapr.placement type=log ver=1.3.0
placement_1 | time="2021-08-24T09:03:27.159573792Z" level=info msg="leader is established." instance=3f2415963b28 scope=dapr.placement type=log ver=1.3.0
pythonapp-dapr_1 | time="2021-08-24T09:03:27.042136674Z" level=fatal msg="couldn't find trust anchors in environment variable DAPR_TRUST_ANCHORS" app_id=pythonapp instance=636e33cae739 scope=dapr.runtime type=log ver=edge
redis_1 | 1:C 24 Aug 2021 09:03:26.133 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 24 Aug 2021 09:03:26.133 # Redis version=6.2.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 24 Aug 2021 09:03:26.133 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
hello-docker-compose_pythonapp-dapr_1 exited with code 1
redis_1 | 1:M 24 Aug 2021 09:03:26.134 * monotonic clock: POSIX clock_gettime
redis_1 | 1:M 24 Aug 2021 09:03:26.135 * Running mode=standalone, port=6379.
redis_1 | 1:M 24 Aug 2021 09:03:26.135 # Server initialized
redis_1 | 1:M 24 Aug 2021 09:03:26.135 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
redis_1 | 1:M 24 Aug 2021 09:03:26.136 * Loading RDB produced by version 6.2.5
redis_1 | 1:M 24 Aug 2021 09:03:26.136 * RDB age 87 seconds
redis_1 | 1:M 24 Aug 2021 09:03:26.136 * RDB memory usage when created 0.77 Mb
redis_1 | 1:M 24 Aug 2021 09:03:26.136 * DB loaded from disk: 0.000 seconds
redis_1 | 1:M 24 Aug 2021 09:03:26.136 * Ready to accept connections
nodeapp-dapr_1 | time="2021-08-24T09:03:27.792156548Z" level=info msg="starting Dapr Runtime -- version edge -- commit 1f9adeed5be68005070ed85b63b52ee41331d4bc" app_id=nodeapp instance=6f70900c093c scope=dapr.runtime type=log ver=edge
nodeapp-dapr_1 | time="2021-08-24T09:03:27.792204756Z" level=info msg="log level set to: info" app_id=nodeapp instance=6f70900c093c scope=dapr.runtime type=log ver=edge
nodeapp-dapr_1 | time="2021-08-24T09:03:27.792342536Z" level=info msg="metrics server started on :9090/" app_id=nodeapp instance=6f70900c093c scope=dapr.metrics type=log ver=edge
nodeapp-dapr_1 | time="2021-08-24T09:03:27.794419449Z" level=fatal msg="couldn't find trust anchors in environment variable DAPR_TRUST_ANCHORS" app_id=nodeapp instance=6f70900c093c scope=dapr.runtime type=log ver=edge
hello-docker-compose_nodeapp-dapr_1 exited with code 1

Support listing of external samples

There is a number of Dapr samples all over GitHub. Given the existing disclaimer about each sample being maintainer by its author, the dapr/samples repo should allow for listing of external samples, ones located in user's repo.

Here are some arguments for this approach:

  • Maintainability over time
  • Users clone only the repo for the sample they want to use (not repo of many samples)
  • Ability to support integrations (e.g. Dockerfile or GitHub actions in root)

This approach would still allow for curated list of samples and the dapr/samples repo would still be the go-to place for listing of Dapr demos/samples.

Few popular examples of this approach:

Add Pluggable Component .NET template

Considerations:

  • It should only be possible to run on UNIX-like systems - Unix Domain Sockets dependency.
  • It should refer to .NET official documentation

Twitter Sentiment Setup Bash Script Issues

Environment Used: macOS / zsh shell

  1. On Demo 3, the docs say to run the bash setup script with the following command:

./setup.sh myDemo westus2 '1.0.0' '1.19.6'

However, when you run it in such manner, the script fails because the positional parameters are out of order - the current script actually expects: ./setup.sh myDemo '1.0.0' westus2 '1.19.6' where the Dapr version precedes the location.

Cross checking how the PowerShell script is written, the order matches the docs (I.E. resourceGroup, location, DaprVersion, K8sVersion)

  1. The default K8s version, 1.19.6, is deprecated and cannot be deployed.

  2. On lines 107 and 108 when the getIp function is called for viewer and publiczipkin, the text output usage: sleep seconds is printed out on the screen every second.

Split demo 1 components

For clarity and to follow pattern from the other demos, split the components from 2020-05-Build/demos/demo1/provider-net/components/producer.yaml into individual files and add the auto-generated files (pubsub.yaml, statestore.yaml) to the .gitignore list.

Emphasis on multiple languages

These samples tend to emphasize the fact that dapr is multi-language neutral and include multiple languages in the sample.

The distributed calculator requires downloading and installing multiple languages just to get going. I see this as a potential barrier.

Would there be a chance of having distributed calculator samples that are only one language as well as the one that shows all the languages? This way we can chose which one resonates more - one that emphasizes that using HTTP and gRPC provides language disintermediation and one that makes it easy for someone who only uses one language and would like a simplified sample.

Add external project eShopOnDapr

Is it possible to add this https://github.com/dotnet-architecture/eShopOnDapr to the External Samples? It is the code sample for the Microsoft free ebook "Dapr for .NET Developers" https://docs.microsoft.com/en-us/dotnet/architecture/dapr-for-net-developers/

Not only does this book have lots of code examples, but it also shows how to use Visual Studio to make containers and then run them with Docker Compose and allows debugging with Visual Studio. All this uses the Visual Studio tooling which makes things much easier! Thanks.

New HowTo use dapr with an ingress controller

Describe the proposal

Add a new sample that extends distributed calculator to demonstrate how we can enable communication from outside world to dapr apps running on a cluster using ingress controller. Most common choices for ingress controllers are NGINX and haproxy.

Update k8s registry references

Describe the feature

Per kubernetes/k8s.io#4780, Kubernetes is migrating its image registry to registry.k8s.io, and this repository is impacted.

We have to update the references of k8s.gcr.io to registry.k8s.io by April 3rd to remain up-to-date.

Here's a quick search for k8s.gcr.io on this repo. [search result]. Note that there may be other valid references (like, in the form of generated code, etc) which we have to be aware of.

Release Note

RELEASE NOTE:

  • Update k8s registry from k8s.gcr.io to registry.k8s.io

dapr-apim-integration sample: No prompt or instructions to install Dapr in Kubernetes

The sample assumes Dapr in already installed on the Kubernetes cluster. The prerequisites do mention "Kubernetes cluster with Dapr" but point to installing Dapr locally.

Proposed fix:

The install steps are:

Install Dapr CLI: https://docs.dapr.io/getting-started/install-dapr-cli/
e.g. on Linux:

wget -q https://raw.githubusercontent.com/dapr/cli/master/install/install.sh -O - | /bin/bash

Then install Dapr in the cluster:

dapr init -k

My environment:

  • Dapr 1.5.1
  • Kubernetes: v1.21.2

What is the approach for docker image repositories on sample repo?

Hi!

I just realized that I missed to change the image for the middleware-clientcredential sample app see here (private repo):

image: cse21.azurecr.io/msgraphapp:sample

I wanted to change this to docker.io/dapriosamples/middleware-msgraphapp:edge because I started by copy the quickstart middleware sample and modified the makefile to create and push the image here:

DOCKER_IMAGE_PREFIX ?=middleware-
APPS ?=msgraphapp
SAMPLE_REGISTRY ?=docker.io/dapriosamples
REL_VERSION ?=edge

But I guess there is no build pipeline set up? How should we handle this?

I could push the image to my docker hub account, but not sure if this is a a good long term approach?

Documentation error?

Hi,

Recently we have decided to give dapr a try with our microservices.
Yesterday when I started to test with docker the following config was strange to me,
the -app-port config on the sidecards looks wrong. Shouldn't it be listening to what the actual app is listening too (It is the same as the cli right? https://docs.dapr.io/reference/cli/dapr-run/)?

I am setting it up with redis pubsub and two dotnet core webapis and with following this config I couldn't get it to work so I change the -app-port from 3000 to the port my app was really listening too and it worked.
But I think maybe its because in your case it is gRPC? I'm not sure.

But thanks for the documentation anyway at least it is there in most cases its not for other libraries/packages. 😊

version: '3'
services:
  ############################
  # Node app + Dapr sidecar
  ############################
  nodeapp:
    build: ./node
    ports:
      - "50002:50002"
    depends_on:
      - redis
      - placement
    networks:
      - hello-dapr
  nodeapp-dapr:
    image: "daprio/daprd:edge"
    command: ["./daprd",
     "-app-id", "nodeapp",
     "-app-port", "3000",
     "-placement-host-address", "placement:50006",
     "-dapr-grpc-port", "50002",
     "-components-path", "/components"]
    volumes:
        - "./components/:/components"
    depends_on:
      - nodeapp
    network_mode: "service:nodeapp"
  ############################
  # Python app + Dapr sidecar
  ############################
  pythonapp:
    build: ./python
    depends_on:
      - redis
      - placement
    networks:
      - hello-dapr
  pythonapp-dapr:
    image: "daprio/daprd:edge"
    command: ["./daprd",
    "-app-id", "pythonapp",
    "-placement-host-address", "placement:50006",
    "-components-path", "/components"]
    volumes:
      - "./components/:/components"
    depends_on:
      - pythonapp
    network_mode: "service:pythonapp"
  ############################
  # Dapr placement service
  ############################
  placement:
    image: "daprio/dapr"
    command: ["./placement", "-port", "50006"]
    ports:
      - "50006:50006"
    networks:
      - hello-dapr
  ############################
  # Redis state store
  ############################
  redis:
    image: "redis:alpine"
    ports:
      - "6380:6379"
    networks:
      - hello-dapr
networks:
    hello-dapr:

Pub-Sub Sample Using .NET

I was unable to find a good Pub-Sub sample using the .NET SDK.

I have created a sample on my own and would like to open a PR to include it in this repo.

Docker compose file to run dapr sidecar and asp.net core web api

Hi , can someone please help me out get up and run dapr sidecar and asp.net core web API application, please suggest any change need to do in my docker compose file. version: '3.4'
services:
deviceapi:
image: ${DOCKER_REGISTRY-}deviceapi
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:80"
depends_on:
- db
networks:
- my-dapr-network
db:
image: "mcr.microsoft.com/mssql/server"
environment:
SA_PASSWORD: "Cr0wc0n@123"
ACCEPT_EULA: "Y"
networks:
- my-dapr-network
deviceapp-dapr:
image: "daprio/daprd:edge"
command: ["./daprd",
"-app-id", "deviceservice",
"-app-port", "5000",
"-placement-host-address", "placement:50006",
"-dapr-grpc-port", "50001",
"-components-path", "/components"]
volumes:
- "./components/:/components"
depends_on:
- deviceapi
network_mode: "service:deviceapi"

placement:
image: "daprio/dapr"
command: ["./placement", "-port", "50006"]
ports:
- "50006:50006"
networks:
- my-dapr-network
redis:
image: "redis:alpine"
ports:
- "6381:6379"
networks:
- my-dapr-network

networks:
my-dapr-network:

Add a sample for TypeScript applications

Describe the proposal

It'd be great if there is also a sample available for a TypeScript based Dapr application.

Currently I'm running the app via

{
  "name": "my-app",
  ...
  "scripts": {
    "dapr": "dapr run --app-id my-app --app-port 3000 ts-node-dev lib/main.ts"
  },
  "dependencies": {
    ...
  },
  "devDependencies": {
    "ts-node-dev": "^1.0.0-pre.44",
    ...
  }
}
npm run dapr

but not sure if this is the most elegant / recommended way for running TS based Dapr applications locally.

Btw., having the samples repo and the docs/howto section (which again contains samples) is very confusing as I've to search always in two places.

dapr-apim-integration sample: event-subscriber missing dapr.io/app-id annotation

In file: https://github.com/dapr/samples/blob/master/dapr-apim-integration/k8s/event-subscriber.yaml

When I run: kubectl get pods

I see no pods for event-subscriber.

When I run kubctl get deploy event-subscriber -o yaml, I see an error under status:

message: 'admission webhook "sidecar-injector.dapr.io" denied the request: value
      for the dapr.io/app-id annotation is empty'

Updating and applying k8s/event-subscriber.yaml fixes this issue:

# dapr.io/id: "event-subscriber"
dapr.io/app-id: "event-subscriber"

My environment:

  • Dapr 1.5.1
  • Kubernetes: v1.21.2

hello-docker-compose zipkin tracing not working

I want to trace call made by python app to node app. This is normally working when I do dapr from command prompt.

  • I am using WSL2 for running docker.

  • Deployment of hello-docker-compose is success too.

To add traceability I have added following thing in docker-compose.

zipkin:
    image: "openzipkin/zipkin"
    ports:
      - "9412:9411"
    networks:
      - hello-dapr  

In components I have added following file. ( trace.yaml)

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: zipkin
  namespace: default
spec:
  tracing:
    samplingRate: "1"
    zipkin:
      endpointAddress: "http://zipkin:9411/api/v2/spans"

I am not able to see any tracing.

To check that zipkin is available on specified endpointAddress , I did following things.

I have run ubuntu container in same hello-dapr network. Try to ping zipkin and it is working so container is there.

Another thing I did is manually load data to zipkin using curl and that also work successful.

Now I am not getting that why python app to nodejs app communication is not traced.

Am I missing something in configuration ?

npm gyp error when trying to run the sample

I am trying to run this hello-typescript sample.

PS > node --version
v16.13.2

When I run the third step npm install, I get the following error.

npm ERR! gyp ERR! cwd E:\Vivek\Trials\Ddd\Dapr\Samples\hello-typescript\node_modules\grpc
npm ERR! gyp ERR! node -v v16.13.2
npm ERR! gyp ERR! node-gyp -v v8.3.0
npm ERR! gyp ERR! not ok
npm ERR! node-pre-gyp ERR! build error 

Not sure what I am missing.

Here is the log file that got generated in the folder C:\Users\UserName\AppData\Local\npm-cache_logs

2022-01-20T04_52_56_304Z-debug.log

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.