Using Aspose.Drawing in Azure Functions with C#

Azure functions are event-based, serverless cloud services. You can use Aspose.Drawing for .NET API in Azure functions for drawing vector graphics or text as per your requirements. This article explains how quickly and easily you can configure the API to use in Azure Functions:

Create an Azure Functions Application

Firstly, please create an HTTP trigger function from the Azure functions project template as shown in the following screenshot:

System.Drawing in Azure Function

Add Aspose.Drawing NuGet Package to the Project

Aspose.Drawing for .NET API is hosted on NuGet gallery. Please add the dependency in the project with the user interface or using the installation command below:

PM> Install-Package Aspose.Drawing

Add code for Drawing an Image

Then, you need to add little code for drawing an image as the API takes care of the minor details. Please replace the following code to Function1.cs file for drawing a gradient and returning the output image for an HTTP request:

Now, copy your Aspose.Drawing.NET.lic license file with Aspose.Drawing licensing information to the project directory, open this file properties from Solution Explorer and set Copy to Output Directory to Copy always. If you do not have the license then you can request a Free Evaluation License to test the API in its full capacity.

Publish the Project to Azure

Then, publish your project to Azure as described in Quickstart: Create your first function in Azure using Visual Studio.

Test the Function in Azure

In the address bar of a browser, append the string /api/Function1 to the base URL and run the request (the full request will look like

Finally, you will see the following drawing result:

Aspose.Drawing in Azure Function


In this article, you have learned how to work with Aspose.Drawing for .NET API in Azure functions. System.Drawing namespace can have compatibility issues in Azure functions so you can easily use Aspose.Drawing API without any issues. Moreover, you can always reach out to us at the Free Support Forum in case of any concerns.

See Also