IRONSOFTWAREHOME

我可以在Azure上使用 .NET 運行 IronBarcode 嗎?

Curtis Chau
Curtis Chau
Updated: 2026年6月29日

可以! IronBarcode 可用於讀取和寫入託管於Azure服務上的 .NET 應用程式中的 QR/條碼。 IronBarcode 已在多個Azure平台上進行了全面測試,包括MVC網站、Azure Functions等更多。


先決條件

1. 安裝 IronBarcode 以開始使用

首先,在NuGet網站上安裝 NuGet 套件。

PM > Install-Package BarCode

作為替代,也可以下載 IronBarcode.dll並新增到您的專案中。


如何操作教學

2. 效能與Azure層級

我們建議至少使用Azure B1 服務方案,因為它適用於大多數使用者的情境。 需要更高吞吐量的系統將需要更高的服務方案。

3. 框架選擇

.NET Standard、Core 和 Framework 專案都與 IronBarcode 相容。

4. 在 Azure 上使用 Docker

在Azure上使用IronBarcode來控制性能和穩定性的一種方法是使用Docker。 要學習如何將 IronBarcode 與 Azure 和 Docker 結合,請查看此教學

5. 官方 Azure Function 支援

IronBarcode 目前支援 Azure Functions V3 和 V4。

運行的 Azure Function 程式碼範例

已在 Azure Functions v3.3.1.0+ 上測試。 這是一個程式碼範例:

using System;
using System.Net;
using System.Net.Http;
using IronBarCode;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System.Net.Http.Headers;

public static class BarcodeFunction
{
    // Azure Function triggered by HTTP request.
    [FunctionName("barcode")]
    public static HttpResponseMessage Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
    {
        log.LogInformation("C# HTTP trigger function processed a request.");

        // Set the license key for IronBarcode if needed.
        IronBarCode.License.LicenseKey = "Key";

        // Create a QR barcode from a string.
        var myBarCode = BarcodeWriter.CreateBarcode("IronBarcode Test", BarcodeEncoding.QRCode);

        // Prepare the HTTP response to return the barcode image.
        var response = new HttpResponseMessage(HttpStatusCode.OK)
        {
            Content = new ByteArrayContent(myBarCode.ToJpegBinaryData())
        };
        
        // Set content headers for attachment and content type.
        response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
        { 
            FileName = $"{DateTime.Now:yyyyMMddmm}.jpg" 
        };
        
        response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");

        return response;
    }
}

在此程式碼中:

  • 我們定義了一個名為 "barcode" 的 Azure Function。
  • 此功能由HTTP請求觸發,並在處理時記錄一條消息。
  • 我們指定了 IronBarcode 的授權鍵(用您的實際授權鍵替換 "Key")。
  • 使用 BarcodeWriter.CreateBarcode 生成QR碼條碼。
  • 條碼圖像被轉換為JPEG格式並包含在HTTP回應中。
  • 回應內容被設定為一個可下載的附件,檔案名是當前日期和時間。
  • 回應內容型別被設定為"image/jpeg",以指示圖像格式。

常見問題

我怎樣才能將條碼功能整合到我的Azure應用中?

您可以使用IronBarcode將條碼功能整合到您的Azure應用中。首先通過命令行安裝IronBarcode的NuGet套件或下載IronBarcode.dll並將其新增到您的專案中。

哪些Azure服務計畫適合處理條碼?

對於大多數使用情況,當使用IronBarcode時推薦使用Azure B1服務計畫。如果您的應用需要更高的吞吐量,可以考慮升級到更高的服務計畫。

IronBarcode與Azure上的所有.NET框架相容嗎?

是的,IronBarcode與.NET Standard、Core和Framework專案相容,允許在Azure上部署應用程式時有靈活性。

我可以使用Docker來提高Azure上的條碼處理性能嗎?

是的,您可以使用Docker在Azure上增強條碼處理的性能和穩定性。提供了詳細的教學來整合IronBarcode與Docker。

IronBarcode程式庫是否支持Azure Functions?

IronBarcode支持Azure Functions V3和V4。它允許在無伺服器環境中無縫整合條碼處理。

Azure Function如何使用IronBarcode處理條碼?

Azure Function可以設置為在使用IronBarcode的HTTP請求觸發時生成QR碼。它記錄消息、設置授權金鑰、使用BarcodeWriter.CreateBarcode建立QR碼,並將圖像作為JPEG文件返回在HTTP回應中。

在Azure Function中建立QR碼需要什麼程式碼?

在Azure Function中,使用IronBarcode透過在函式中調用BarcodeWriter.CreateBarcode來建立QR碼,然後可將生成的QR碼作為JPEG圖像返回在HTTP回應中。

Is it necessary to set a license key for using IronBarcode in Azure Functions?

Yes, setting a license key for IronBarcode is necessary in Azure Functions to activate the library and remove any limitations.

What file format is used for barcodes generated by IronBarcode in Azure Functions?

Barcodes generated by IronBarcode in Azure Functions are converted to JPEG format for the HTTP response.

How are content headers set for barcode images in Azure Functions using IronBarcode?

Content headers are set to define the barcode image as a downloadable attachment with the current date and time as part of the file name.

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

準備好開始了嗎?

Nuget Downloads 2,422,100版本:2026.9剛剛發布

立即獲取您的免費30天試用金鑰
不需要信用卡或帳戶建立
C# NuGet程式庫,用於PDF
通過NuGet安裝

版本: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 在解決方案資源管理器中,右鍵點擊References,管理NuGet包
  2. 選擇瀏覽並搜尋"IronBarCode"
  3. 選擇包並安裝
C# PDF DLL
下載DLL

版本: 2026.9

  1. 下載並解壓IronBarCode至您的Solution目錄中的~/Libs等位置
  2. 在Visual Studio解決方案資源管理器中右鍵點擊References,選擇瀏覽,"IronBarCode.dll"

$999起的授權費用

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成下方表單或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立