Git Product home page Git Product logo

aspire-devtunnels-eventgrid's Introduction

aspire-devtunnels-eventgrid

Experiments with APIs for local dev env with dotnet Aspire, Azure EventGrid, and Microsoft Dev tunnels.

Motivation

In many Azure resources, such as Azure Communication Services, a common workflow is to use EventGrid to subscribe to events via e.g. webhooks.

This repo explores possible ways to organize nice development experience for EventGrid subscriptions with Aspire and how to have webhooks working locally with Dev tunnels.

Pre-requisites

  1. Install dev tunnels winget install Microsoft.devtunnel

  2. Install az cli: winget install -e --id Microsoft.AzureCLI

  3. Have an Azure Subscription where you can create resources

Running the sample

  1. Run .\init.ps1

    • This will use devtunnels CLI to create a tunnel called "aspire-tunnel" and expose local port 5099 (on which the SampleWebApi is hosted)

    • It will also create an Azure Communication Services resource just to be able to have an EventGrid instance and to test subscribing to some events.

    • The script will ask you to enter name of the Azure subscription you wish to deploy resources to.

    • It will create a resource group called rg-aspire-devtunnels-test and the Communication resource called acs-<randomname>.

    • Finally it will initalize environment variables required by the app:

    • ConnectionStrings__ACS - to add the ACS resource (even though it is not really used)

    • ACS_RESOURCE_ARM_ID - Azure id of the ACS resource to be passed to EventGrid's conrol plane SDK and subscribe.

  2. Build and run AspireTunnels.sln.

    • This should start up devtunnels via Aspire host

    • It will also use the devtunnels SDK to find out the public uri that got assigned to the devtunnel.

    • This public uri is then passed via environment variable EndpointUrl to the SampleWebApi process

    • The SampleWebApi process uses a background service EventGridSubscriptionService to wait until the app is ready and then self-subscribe to EventGrid using the EndpointUrl.

If everything works OK you should see

...
Got /events callback
We subscribed successfully

In the SampleWebApi logs.

aspire-devtunnels-eventgrid's People

Contributors

mbakalov avatar

Watchers

 avatar

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.