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上使用Docker是获得对IronBarcode性能和稳定性控制能力的一种方法。 要了解如何在Azure和Docker上使用IronBarcode,请查看本教程

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生成二维码条形码。
  • 条形码图像被转换为JPEG格式,并包含在HTTP响应中。
  • 响应内容被设置为可下载附件,文件名为当前日期和时间。
  • 响应内容类型被设置为"image/jpeg"以指示图像格式。

常见问题解答

如何将条码功能集成到我的 Azure 应用程序中?

您可以通过使用 IronBarcode 将条码功能集成到您的 Azure 应用程序中。首先通过命令行安装 IronBarcode NuGet 包或下载 IronBarcode.dll 并添加到您的项目中。

哪些 Azure 服务计划适合条码处理?

在使用 IronBarcode 时,对于大多数用例,推荐使用 Azure B1 服务计划。如果您的应用程序需要更高的吞吐量,请考虑升级至更高的服务计划。

IronBarcode 是否与 Azure 上的所有 .NET Framework兼容?

是的,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,当通过 HTTP 请求触发时,使用 IronBarcode 生成 QR 码。它记录一条消息、设置许可证密钥、使用 BarcodeWriter.CreateBarcode 创建 QR 码,并在 HTTP 响应中以 JPEG 文件返回图像。

在 Azure Function 中创建 QR 码需要哪些代码?

在 Azure Function 中,使用 IronBarcode 通过调用 BarcodeWriter.CreateBarcode 创建 QR 码。生成的 QR 码可以作为 HTTP 响应中的 JPEG 图像返回。

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 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

...
阅读更多

准备开始了吗?

Nuget Downloads 2,422,100版本:2026.9刚刚发布

立即获取您的免费30 天试用密钥
无需信用卡或创建账户
C# 用于 PDF 的 NuGet 库
通过 NuGet 安装

版本: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 在解决方案资源管理器中,右键点击引用,管理 NuGet 包
  2. 选择浏览并搜索 "IronBarcode"
  3. 选择包并安装
C# PDF DLL
下载 DLL

版本: 2026.9

  1. 下载并将 IronBarCode 解压到解决方案目录中的 ~/Libs 等位置
  2. 在 Visual Studio 解决方案资源管理器中,右键单击引用。选择浏览,"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 天试用密钥
无需信用卡或创建账户