Can I Run IronXL with .NET on Azure?

This article was translated from English: Does it need improvement?
Translated
View the article in English

是的,IronXL 可以在 Azure 上用於在 C# 和 VB .NET 應用程式中生成 QR 和條碼,還可從掃描圖像中讀取條碼和 QR 碼。

IronXL 在多個 Azure 平台上進行了全面測試,包括 MVC 網站、Azure Functions 等許多平台。


class="main-content__segment-title">步驟 1

1. 安裝 IronXL 開始使用

首先使用 NuGet 安裝:https://www.nuget.org/packages/IronXL.Excel

Install-Package IronXL.Excel

class="main-content__segment-title">教程指南

2. 性能和 Azure 等級

我們建議 Azure B1 託管級別非常適合我們最終用戶的庫需求。 如果他們正在創建一個高吞吐量系統,可能需要升級。

3. 框架選擇

我們發現 IronXL 的 Core 和 Framework 版本均可在 Azure 上運行。 .NET Standard 應用程式在速度和穩定性上似乎有一些性能優勢,但過程中佔用更多的記憶體。

Azure 免費層託管速度慢

Azure 免費和共享層以及消費計畫不適合 QR 處理。 我們推薦 Azure B1 託管/高級計畫,這是我們本身所使用的。

4. Azure 上的 Docker

提升在 Azure 上控制性能能力的方法之一是從 Docker 容器內使用 IronXL 應用程式和功能。

我們有一個綜合的 IronXL Azure Docker 教程,適用於 Linux 和 Windows 實例,建議閱讀。

5. 官方 Azure Functions 支援

IronXL 支援 Azure Function(Azure Functions V3)。 目前尚未測試 V4,但已在我們的計劃中。

工作中的 Azure Functions 代碼範例

已在 Azure Functions v3.3.1.0+ 上測試。 以下是示範代碼:

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
$vbLabelText   $csharpLabel

常見問題解答

如何在 Azure 上執行 .NET 應用程式?

您可以使用 IronXL 在 Azure 上執行 .NET 應用程式。它支援在 C# 和 VB .NET 應用程式中產生二維碼和條碼,並從掃描的圖像中讀取它們。 IronXL 已在包括 MVC 網站和 Azure Functions 在內的各種 Azure 平台上進行了測試。

為了獲得最佳效能,建議使用哪些 Azure 託管等級?

為了獲得 IronXL 的最佳效能,我們建議使用 Azure B1 託管等級。如果您正在設計高吞吐量系統,請考慮升級到更高等級。

哪個 .NET 框架最適合 Azure?

IronXL 在 Azure 上同時支援 .NET Core 和 .NET Framework。不過,.NET Standard 應用程式在速度和穩定性方面略勝一籌,但記憶體佔用也會更高。

Azure 的免費方案是否足以滿足二維碼處理需求?

不建議使用 Azure 的免費層級和共用層級以及按需付費方案來處理 IronXL 的二維碼。我們建議使用 Azure B1 託管或進階計劃以獲得更好效能。

Docker 能否用於管理 Azure 上的 IronXL 應用程式?

是的,您可以使用 Docker 管理 Azure 上的 IronXL 應用程式和函數。這種配置可以更好地控制性能。我們提供了適用於 Linux 和 Windows 執行個體的詳細 Azure Docker 教學。

IronXL 是否支援 Azure Functions?

是的,IronXL 支援 Azure Functions V3。目前正在進行 Azure Functions V4 的測試,並計劃在未來擴展支援範圍。

如何在 Azure 上安裝 IronXL?

您可以使用以下指令透過 NuGet 安裝 IronXL: nuget install IronXL.Excel

是否有將 IronXL 與 Azure Functions 結合使用的範例?

是的,本文提供了一個 Azure 函數範例程式碼,用於處理 HTTP 請求並傳回 Excel 檔案。此範例已在 Azure Functions v3.3.1.0 及更高版本上測試通過。

Curtis Chau
技術作家

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。

準備好開始了嗎?
Nuget 下載 1,686,155 | 版本: 2025.11 剛剛發布