Git Product home page Git Product logo

globoticket-dapr's Introduction

Dapr Fundamentals GloboTicket Demo Application

This application is intended to demonstrate the basics of using Dapr to build a microservices application. It is the demo project for the Pluralsight Dapr 1 Fundamentals course, by Mark Heath.

This version of the code is using Dapr 1.13

Running the app locally

The recommended way for running locally is to use self-hosted mode (option 1). I have also managed to get it running in Docker Compose, although that option has not been tested so much.

Option 1 - Running self-hosted from the command line

Prerequisites: You need to have the Dapr CLI installed, as well as Docker installed (e.g. Docker Desktop for Windows), and to have set up Dapr in self-hosted mode with dapr init

And in order to use the email sending feature, you'll want a local container running maildev, which you can start using: docker run -d -p 1080:1080 -p 1025:1025 maildev/maildev. If you need a dummy credit card number to place an order you can use 4242424242424242 or 5555555555554444

Open three terminal windows. In the frontend folder run start-self-hosted.ps1. Do the same in the catalog and ordering folders. The ports used are specified in the PowerShell start up scripts. The frontend app will be available at http://localhost:5266/. The catalog service will be at http://localhost:5016/swagger/index.html, and the ordering service at http://localhost:5293/swagger/index.html

You can view Zipkin traces at http://localhost:9411/zipkin/? You can see the emails sent by the ordering service using maildev on: http://localhost:1080/#/

Option 2 - Running with Docker Compose

In same folder as the docker-compose.yml file, run docker-compose build then docker-compose up. The frontend service will be at https://localhost:5001.

Note: The Docker Compose version has its own components folder, as the relative path of the local secrets is different, and redis is not on localhost. You will be able to access Zipkin traces on: http://localhost:9412/zipkin/

You can see the emails sent by the ordering service using maildev on: http://localhost:1080/#/

Option 3 - Running with Docker Compose in Visual Studio 2022

Set the startup project to Docker Compose. If you've used option 1, make sure the other Docker Compose containers are removed or there will be a name conflict. The frontend service will be at https://localhost:5001. The catalog service will be at http://localhost:5003/swagger/index.html, and the ordering service at http://localhost:5004/swagger/index.html. You will be able to access Zipkin traces on: http://localhost:9412/zipkin/

Architecture Overview

  • The frontend microservice is a simple ASP.NET Core 6 website. It allows visitors to browse the catalog of events, and place an order for tickets
  • The catalog microservice provides the list of events that tickets can be purchased for. To keep this demo as simple as possible, the catalog microservice returns a hard-coded in-memory list. Created with dotnet new webapi -o catalog --no-https (no https because we're going to rely on dapr for securing communication between microservices). A dapr cron job calls a scheduled endpoint on this.
  • The ordering microservice takes new orders. It receives the order via pub-sub messaging. It sends an email to thank the user for purchasing. A dapr output

Deploying to Kubernetes (AKS) on Azure

The aks-deploy.ps1 PowerShell script shows the steps needed to deploy this to Azure. Don't run this directly. You'll need the Azure CLI installed, and you'll also need to pick unique resource names that are available. The script includes example commands you can use to check it's all working as expected.

Troubleshooting notes

  • the maildev docker image switched its default ports from 80 & 25 to 1080 and 1025, so make sure you're using the correct email YAML component definition from this repo if you're having troubles with those
  • there is a known issue when running locally with the mDNS resolution in Dapr where if you are running certain VPNs or CISCO networking apps it can cause it to fail. The workaround is usually to temporarily stop the offending software. In the GloboTicket app, this error would cause the homepage to fail to load, unable to communicate with the catalog service.
  • When running on AKS, after you've upgraded Dapr, it's a good idea to restart the deployments. The AKS demo script has an example.

globoticket-dapr's People

Contributors

markheath 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

Watchers

 avatar  avatar  avatar  avatar

globoticket-dapr's Issues

fail to invoke, id: catalog, err: couldn't find service: catalog

Hi Mark,

I am running into an issue with dapr and the sample code. I start the self-hosted catalog, works fine, I can access the catalog Swagger file over the http port of the application, but I cannot invoke the service using dapr. I have already upgraded dapr and the CLI to the latest version.

➜ curl http://localhost:3501/v1.0/invoke/catalog/method/Event
{"errorCode":"ERR_DIRECT_INVOKE","message":"fail to invoke, id: catalog, err: couldn't find service: catalog"}%

The port of the service is 3501 - and dapr list returns this:

➜ dapr list
  APP ID   HTTP PORT  GRPC PORT  APP PORT  COMMAND     AGE  CREATED              DAPRD PID  CLI PID  APP PID  RUN TEMPLATE PATH  
  catalog  3501       49904      5016      dotnet run  43s  2023-04-03 14:10.12  30203      30195    30204

To me that looks fine.. but I have no clue why the dapr invocation is failing. Any ideas?

Thank you!
Thomas

Certificate error when running via docker-compose file locally

Hi, When I run the solution via docker-compose file on Windows 10 machine I get the following error when starting up frontend project container:
Unhandled exception. System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.
globoticket-dapr-main-frontend-1 | To generate a developer certificate run 'dotnet dev-certs https'. To trust the certificate (Windows and macOS only) run 'dotnet dev-certs https --trust'.
I run the above mentioned command but to no avail.
Could you please help me solve the problem, If you could?. Thanks.

Self-hosted Dapr on multiple machines. Is it possible?

I would like to run self-hosted services on different hosts. If it is possible please provide some example or link to documentation with details. My Monolith is running on several physical machines but is not ready for migration to .NET core and as result I can't use Kubernetes. Single option for me is self-hosted dapr sidecars but I can't see if it is even possible.

Microservices fail to start in AKS

I have run through your deployment script twice now and both times I get the same failure

2023-08-03T10:00:58.374Z time="2023-08-03T10:00:58.374017639Z" level=fatal msg="process component shopstate error: [INIT_COMPONENT_FAILURE]: initialization error occurred for shopstate (state.azure.blobstorage/v1): failed to create Azure Storage container statestore: PUT https://globoticketstate.blob.core.windows.net/statestore\n--------------------------------------------------------------------------------\nRESPONSE 403: 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nERROR CODE: AuthenticationFailed\n--------------------------------------------------------------------------------\n\ufeffAuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.\nRequestId:737bef3c-b01e-013b-3bf1-c5235d000000\nTime:2023-08-03T10:00:58.2691756ZThe MAC signature found in the HTTP request 'Xn052Bc+HpgkZO+50FvZIlra7XyVbgsrN/QHW1FzTUI=' is not the same as any computed signature. Server used following string to sign: 'PUT\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:Thu, 03 Aug 2023 10:00:57 GMT\nx-ms-version:2020-10-02\n/globoticketstate/statestore\nrestype:container'.\n--------------------------------------------------------------------------------\n" app_id=frontend instance=frontend-7bb9cd77b8-bxkpp scope=dapr.runtime type=log ver=1.11.2

A container called statestore is created in Azure. So perhaps it is a permissions thing but I got no failuires in putting the keys into Kuberneties.
I get this failure for all 3 microservices. It appears the microservice is running but the dapr sidecar is not.

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.