Can I Run IronXL with .NET on Azure?
Yes, IronXL can be used on Azure to generate QR & Barcodes in C# & VB .NET Applications, and also read Barcodes & QR Codes from scanned images.
IronXL has been thoroughly tested on multiple Azure platforms including MVC websites, Azure Functions, and many more.
Step 1
1. Install IronXL to Get Started
First install with NuGet: https://www.nuget.org/packages/IronXL.Excel
Install-Package IronXL.Excel
How to Tutorial
2. Performance and Azure Tiers
We recommend that Azure B1 hosting levels are very suitable for our end users' Library needs. If they are creating a high throughput system, this may need to be upgraded.
3. Framework Choice
We have found that IronXL for Core and for Framework both work on Azure. .NET Standard applications seem to have a small performance advantage on speed and stability, but use more memory in process.
Azure free tier hosting is slow
Azure free and shared tiers, and the consumption plan, are not suitable for QR processing. We recommend Azure B1 hosting/Premium plan, which is what we use ourselves.
4. Docker on Azure
One way to gain the ability to control performance on Azure is to use IronXL applications and Functions from within Docker Containers.
We have a comprehensive IronXL Azure Docker tutorial for Linux and Windows instances and it is recommended reading.
5. Official Azure Function Support
IronXL supports Azure Function (Azure Functions V3). It hasn't been tested with V4 till now, but it is in our queue.
Working Azure Function Code Example
Tested on Azure Functions v3.3.1.0+. Here is a sample code:
using System.Net;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using IronXL;
using System.Net.Http.Headers;
// This is an Azure Function that processes an HTTP request and returns an Excel file
[FunctionName("excel")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
// Log the processing of the request
log.LogInformation("C# HTTP trigger function processed a request.");
// Set the IronXL license key
IronXL.License.LicenseKey = "Key";
// Load an existing workbook
var workBook = WorkBook.Load("test-wb.xlsx");
// Create a response with the workbook content as an attachment
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(workBook.ToByteArray());
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx"
};
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// Return the response
return result;
}
using System.Net;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using IronXL;
using System.Net.Http.Headers;
// This is an Azure Function that processes an HTTP request and returns an Excel file
[FunctionName("excel")]
public static HttpResponseMessage Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
// Log the processing of the request
log.LogInformation("C# HTTP trigger function processed a request.");
// Set the IronXL license key
IronXL.License.LicenseKey = "Key";
// Load an existing workbook
var workBook = WorkBook.Load("test-wb.xlsx");
// Create a response with the workbook content as an attachment
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(workBook.ToByteArray());
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx"
};
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
// Return the response
return result;
}
Imports System.Net
Imports Microsoft.Azure.WebJobs
Imports Microsoft.Azure.WebJobs.Extensions.Http
Imports Microsoft.AspNetCore.Http
Imports Microsoft.Extensions.Logging
Imports IronXL
Imports System.Net.Http.Headers
' This is an Azure Function that processes an HTTP request and returns an Excel file
<FunctionName("excel")>
Public Shared Function Run(<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route := Nothing)> ByVal req As HttpRequest, ByVal log As ILogger) As HttpResponseMessage
' Log the processing of the request
log.LogInformation("C# HTTP trigger function processed a request.")
' Set the IronXL license key
IronXL.License.LicenseKey = "Key"
' Load an existing workbook
Dim workBook = WorkBook.Load("test-wb.xlsx")
' Create a response with the workbook content as an attachment
Dim result = New HttpResponseMessage(HttpStatusCode.OK)
result.Content = New ByteArrayContent(workBook.ToByteArray())
result.Content.Headers.ContentDisposition = New ContentDispositionHeaderValue("attachment") With {.FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx"}
result.Content.Headers.ContentType = New MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
' Return the response
Return result
End Function
Frequently Asked Questions
How can I run .NET applications on Azure?
You can use IronXL to run .NET applications on Azure. It allows for generating QR & Barcodes in C# & VB .NET applications and reading them from scanned images. It has been tested on various Azure platforms, including MVC websites and Azure Functions.
What are the recommended Azure hosting levels for optimal performance?
For optimal performance with IronXL, we recommend Azure B1 hosting levels. If you're designing a high throughput system, consider upgrading to a higher tier.
Which .NET framework works best on Azure?
IronXL works on both .NET Core and .NET Framework on Azure. However, .NET Standard applications provide a slight performance edge in speed and stability, albeit with increased memory usage.
Is Azure's free tier sufficient for QR processing?
Azure's free and shared tiers, along with the consumption plan, are not recommended for QR processing with IronXL. Instead, we suggest using Azure B1 hosting or a Premium plan for better performance.
Can Docker be used to manage IronXL applications on Azure?
Yes, you can use Docker to manage IronXL applications and Functions on Azure. This setup allows better control over performance. A detailed Azure Docker tutorial is available for both Linux and Windows instances.
Does IronXL support Azure Functions?
Yes, IronXL supports Azure Functions V3. Testing for Azure Functions V4 is underway, with plans to extend support in the future.
How do I install IronXL for use on Azure?
You can install IronXL via NuGet using the command: nuget install IronXL.Excel
.
Is there an example of using IronXL with Azure Functions?
Yes, the article provides a sample Azure Function code that processes an HTTP request and returns an Excel file. This example is tested on Azure Functions v3.3.1.0+.