Code Monkey home page Code Monkey logo

azurefunctions-eventgrid's Introduction

Azure Functions Event Grid binding

An easy to use Azure Functions output binding for Azure Event Grid.

Moving on

When I created this package, there wasn't an Event Grid binding available for Azure Functions. Nowadays, there is one provided to you by the team. I recommend you start using the binding which is supported by the team in favor of this one. More information can be found in the docs..

Badges

Code Smells Maintainability Rating Quality Gate Status Security Rating Technical Debt Vulnerabilities

Download

The compiled version can be downloaded via NuGet (https://www.nuget.org/packages/AzureFunctions.EventGridBinding/), so you can use it in your project.

Usage

A sample on how you can use the output binding is as follows.

[FunctionName("Test")]
public static async Task<IActionResult> Run(
	[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
	[EventGrid(
		// The endpoint of your Event Grid Topic, this should be specified in your application settings of the Function App
		TopicEndpoint = "EventGridBindingSampleTopicEndpoint",
		// This is the secret key to connect to your Event Grid Topic. To be placed in the application settings.
		TopicKey = "EventGridBindingSampleTopicKey")]
	IAsyncCollector<Event> outputCollector,
	ILogger log)
{
	log.LogInformation("Executing the Test function");

	// Create the actual `Data` object you want to publish to Event Grid
	var customEvent = new MyCustomEvent
	{
		Identifier = 1,
		Name = "Jan",
		Product = "Azure Functions"
	};
	// Specify some meta data of the message you want to publish to Event Grid
	var myTestEvent = new Event
	{
		EventType = nameof(MyCustomEvent),
		Subject = "Jandev/Samples/CustomTestEvent",
		Data = customEvent
	};

	// Add the event to the IAsyncCollector<T> in order to get your event published.
	await outputCollector.AddAsync(myTestEvent);

	log.LogInformation("Executed the Test function");

	return new OkObjectResult($"Sending {customEvent.Identifier}.");
}

private class MyCustomEvent
{
	public int Identifier { get; set; }
	public string Name { get; set; }
	public string Product { get; set; }
}

The publishing of the events will be executed after the Azure Function is finished, in the FlushAsync method of the IAsyncCollector<T>.

azurefunctions-eventgrid's People

Contributors

hey-mikey avatar jandev avatar jayendranarumugam avatar

Stargazers

 avatar

Watchers

 avatar  avatar

azurefunctions-eventgrid's Issues

Create GitHub Action for building the package & release to NuGet

The package is now being published via a build pipeline in Azure DevOps
I'd like to see this being published via a GitHub Action and only push to NuGet.org when something happens on the master branch.

The feature branches and develop branches can create prerelease packages as an artifact but not publish to NuGet.org

Work breakdown:

  • Create a GH for CI of incoming PR's (fork or local), only doing build (& tests when available)
  • Create an Action for CI for changes on develop, which is doing build, tests & creates a beta/prerelease package
  • Create an Action for master branch which will build with Release configuration, test, package & push to Nuget.org

Version number of package & project should update accordingly.

Update NuGet API key

The current API key for publishing to the NuGet feed is expired.
Please create a new one and add it to the secrets of this repository.

Creating release fails

The creation of a release looks like this.

    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
      with:
        tag_name: ${{ github.ref }}
        release_name: Release ${{ github.ref }}
        prerelease: true

On consecutive builds, this fails.

The Action should be reworked to use GitVersion.

Workflows are referencing vulnerable actions

Hello, there!

As part of the university research we are currently doing regarding the security of Github Actions, we noticed that one or many of the workflows that are part of this repository are referencing vulnerable versions of the third-party actions. As part of a disclosure process, we decided to open issues to notify GitHub Community.

Please note that there are could be some false positives in our methodology, thus not all of the open issues could be valid. If that is the case, please let us know, so that we can improve on our approach. You can contact me directly using an email: ikoishy [at] ncsu.edu

Thanks in advance

  1. The workflow developrelease.yml is referencing action gittools/actions/gitversion/setup using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  2. The workflow developrelease.yml is referencing action gittools/actions/gitversion/execute using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  3. The workflow main.yml is referencing action gittools/actions/gitversion/setup using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.
  4. The workflow main.yml is referencing action gittools/actions/gitversion/execute using references v0.9.9. However this reference is missing the commit 90150b4 which may contain fix to the vulnerability.

The vulnerability fix that is missing by actions' versions could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider updating the reference to the action.

If you end up updating the reference, please let us know. We need the stats for the paper :-)

Add support to inject an earlier created HttpClient

When a new EventGridClient is spun up, there's also a new HttpClient spun up underneath.

It would be nice if this can be injected via the proper constructor of the EventGridClient.

  • Add an optional property to the attribute
  • If != null, use this HttpClient, otherwise use a different constructor.

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.