{"id":13288991,"url":"https://github.com/Azure-Samples/pubsub-dapr-csharp-servicebus","last_synced_at":"2025-03-10T06:33:55.091Z","repository":{"id":45207950,"uuid":"512870418","full_name":"Azure-Samples/pubsub-dapr-csharp-servicebus","owner":"Azure-Samples","description":"A complete microservice application featuring Dapr Pub-Sub, deployed to Azure Container Apps and Azure Service Bus Topics with dead-lettering support.","archived":false,"fork":false,"pushed_at":"2024-06-07T02:02:48.000Z","size":276,"stargazers_count":26,"open_issues_count":2,"forks_count":17,"subscribers_count":14,"default_branch":"main","last_synced_at":"2024-07-29T17:04:26.552Z","etag":null,"topics":["azd-templates","azure","dapr"],"latest_commit_sha":null,"homepage":"","language":"Bicep","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Azure-Samples.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-11T18:37:05.000Z","updated_at":"2024-06-13T14:59:41.000Z","dependencies_parsed_at":"2024-10-23T09:30:55.189Z","dependency_job_id":"971c1464-c1ab-4608-93c0-ac3b6fd8db87","html_url":"https://github.com/Azure-Samples/pubsub-dapr-csharp-servicebus","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azure-Samples%2Fpubsub-dapr-csharp-servicebus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azure-Samples%2Fpubsub-dapr-csharp-servicebus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azure-Samples%2Fpubsub-dapr-csharp-servicebus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Azure-Samples%2Fpubsub-dapr-csharp-servicebus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Azure-Samples","download_url":"https://codeload.github.com/Azure-Samples/pubsub-dapr-csharp-servicebus/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242805616,"owners_count":20187996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azd-templates","azure","dapr"],"created_at":"2024-07-29T17:00:17.829Z","updated_at":"2025-03-10T06:33:55.069Z","avatar_url":"https://github.com/Azure-Samples.png","language":"Bicep","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\n---\npage_type: sample\nlanguages:\n- azdeveloper\n- csharp\n- bicep\nproducts:\n- azure\n- azure-container-apps\n- azure-service-bus\nurlFragment: pubsub-dapr-csharp-servicebus\nname: Microservice communication using pubsub (async)(C#)\ndescription: Create a publisher microservice and a subscriber microservice with C# to demonstrate how Dapr enables a publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscribers will listen for messages of specific topics. \n---\n--\u003e\n\u003c!-- YAML front-matter schema: https://review.learn.microsoft.com/en-us/help/contribute/samples/process/onboarding?branch=main#supported-metadata-fields-for-readmemd --\u003e\n\n# Microservice communication using pubsub (async)\n\n![](images/pubsub-diagram.png)\n\nIn this quickstart, you'll create a publisher microservice and a subscriber microservice to demonstrate how Dapr enables a publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscribers will listen for messages of specific topics. See [Why Pub-Sub](#why-pub-sub) to understand when this pattern might be a good choice for your software architecture.\n\nFor more details about this quickstart example please see the [Pub-Sub Quickstart documentation](https://docs.dapr.io/getting-started/quickstarts/pubsub-quickstart/).\n\nVisit [this](https://docs.dapr.io/developing-applications/building-blocks/pubsub/) link for more information about Dapr and Pub-Sub.\n\n\u003e **Note:** This example leverages the Dapr client SDK.  If you are looking for the example using only HTTP [click here](../http).\n\nThis quickstart includes one publisher:\n\n- Dotnet client message generator `checkout` \n\nAnd one subscriber: \n \n- Dotnet subscriber `order-processor`\n\n### Pre-requisites\n\nFor this example, you will need:\n\n- [Dapr CLI](https://docs.dapr.io/getting-started)\n- [.NET 6 SDK](https://dotnet.microsoft.com/download)\n\u003c!-- IGNORE_LINKS --\u003e\n- [Docker Desktop](https://www.docker.com/products/docker-desktop)\n\u003c!-- END_IGNORE --\u003e\n\n### Run Dotnet message subscriber with Dapr\n\n1. Navigate to the directory and install dependencies: \n\n\u003c!-- STEP\nname: Install Dotnet dependencies\n--\u003e\n\n```bash\ncd ./order-processor\ndotnet restore\ndotnet build\n```\n\u003c!-- END_STEP --\u003e\n2. Run the Dotnet subscriber app with Dapr: \n\n\u003c!-- STEP\nname: Run Dotnet subscriber\nexpected_stdout_lines:\n  - \"You're up and running! Both Dapr and your app logs will appear here.\"\n  - '== APP == Subscriber received : Order { OrderId = 2 }'\n  - \"Exited Dapr successfully\"\n  - \"Exited App successfully\"\nexpected_stderr_lines:\nworking_dir: ./order-processor\noutput_match_mode: substring\nbackground: true\nsleep: 10\n--\u003e\n\n\n```bash\ndapr run --app-id order-processor --components-path ../components/ --app-port 7001 -- dotnet run --project .\n```\n\n\u003c!-- END_STEP --\u003e\n### Run Dotnet message publisher with Dapr\n\n3. Navigate to the directory and install dependencies: \n\n\u003c!-- STEP\nname: Install Dotnet dependencies\n--\u003e\n\n```bash\ncd ./checkout\ndotnet restore\ndotnet build\n```\n\u003c!-- END_STEP --\u003e\n4. Run the Dotnet publisher app with Dapr: \n\n\u003c!-- STEP\nname: Run Dotnet publisher\nexpected_stdout_lines:\n  - \"You're up and running! Both Dapr and your app logs will appear here.\"\n  - '== APP == Published data: Order { OrderId = 1 }'\n  - '== APP == Published data: Order { OrderId = 2 }'\n  - \"Exited App successfully\"\n  - \"Exited Dapr successfully\"\nexpected_stderr_lines:\nworking_dir: ./checkout\noutput_match_mode: substring\nbackground: true\nsleep: 10\n--\u003e\n    \n```bash\ndapr run --app-id checkout --components-path ../components/ -- dotnet run --project .\n```\n\n\u003c!-- END_STEP --\u003e\n\n```bash\ndapr stop --app-id order-processor\n```\n\n### Deploy apps to Azure (Azure Container Apps, Azure Service Bus)\n\n#### Deploy to Azure for dev-test\n\nNOTE: make sure you have Azure Dev CLI pre-reqs [here](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux\u0026pivots=os-windows) and are on version 0.9.0-beta.3 or greater.\n\n5. Run the following command to initialize the project. \n\n```bash\nazd init --template https://github.com/Azure-Samples/pubsub-dapr-csharp-servicebus\n``` \n\nThis command will clone the code to your current folder and prompt you for the following information:\n\n- `Environment Name`: This will be used as a prefix for the resource group that will be created to hold all Azure resources. This name should be unique within your Azure subscription.\n\n6. Run the following command to package a deployable copy of your application, provision the template's infrastructure to Azure and also deploy the application code to those newly provisioned resources.\n\n```bash\nazd up\n```\n\nThis command will prompt you for the following information:\n- `Azure Location`: The Azure location where your resources will be deployed.\n- `Azure Subscription`: The Azure Subscription where your resources will be deployed.\n\n\u003e NOTE: This may take a while to complete as it executes three commands: `azd package` (packages a deployable copy of your application),`azd provision` (provisions Azure resources), and `azd deploy` (deploys application code). You will see a progress indicator as it packages, provisions and deploys your application.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAzure-Samples%2Fpubsub-dapr-csharp-servicebus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAzure-Samples%2Fpubsub-dapr-csharp-servicebus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAzure-Samples%2Fpubsub-dapr-csharp-servicebus/lists"}