IronBarcode 开始 生成 Azure 支持 我可以在 Azure 上使用 .NET 运行 IronBarcode 吗? Curtis Chau 已更新:七月 24, 2025 下载 IronBarcode NuGet 下载 DLL 下载 免费试用 法学硕士副本 法学硕士副本 将页面复制为 Markdown 格式,用于 LLMs 在 ChatGPT 中打开 向 ChatGPT 咨询此页面 在双子座打开 向 Gemini 询问此页面 在双子座打开 向 Gemini 询问此页面 打开困惑 向 Perplexity 询问有关此页面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 复制链接 电子邮件文章 This article was translated from English: Does it need improvement? Translated View the article in English 是的! IronBarcode可以用于在Azure服务托管的.NET应用程序中读取和写入QR/条形码。 IronBarcode已在多个Azure平台上进行了彻底测试,包括MVC网站、Azure Functions等。 先决条件 1. 安装IronBarcode以开始使用 首先,在NuGet网站上安装NuGet包。 Install-Package BarCode As an alternative, the IronBarcode.dll could also be downloaded and added to your project. 如何使用教程 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; } } 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; } } Imports System Imports System.Net Imports System.Net.Http Imports IronBarCode Imports Microsoft.AspNetCore.Http Imports Microsoft.Azure.WebJobs Imports Microsoft.Azure.WebJobs.Extensions.Http Imports Microsoft.Extensions.Logging Imports System.Net.Http.Headers Public Module BarcodeFunction ' Azure Function triggered by HTTP request. <FunctionName("barcode")> Public Function Run(<HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route := Nothing)> ByVal req As HttpRequest, ByVal log As ILogger) As HttpResponseMessage 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. Dim myBarCode = BarcodeWriter.CreateBarcode("IronBarcode Test", BarcodeEncoding.QRCode) ' Prepare the HTTP response to return the barcode image. Dim response = New HttpResponseMessage(HttpStatusCode.OK) With {.Content = New ByteArrayContent(myBarCode.ToJpegBinaryData())} ' Set content headers for attachment and content type. response.Content.Headers.ContentDisposition = New ContentDispositionHeaderValue("attachment") With {.FileName = $"{DateTime.Now:yyyyMMddmm}.jpg"} response.Content.Headers.ContentType = New MediaTypeHeaderValue("image/jpeg") Return response End Function End Module $vbLabelText $csharpLabel 在此代码中: 我们定义一个名为"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,当通过 HTTP 请求触发时,使用 IronBarcode 生成 QR 码。它记录一条消息、设置许可证密钥、使用 BarcodeWriter.CreateBarcode 创建 QR 码,并在 HTTP 响应中以 JPEG 文件返回图像。 在 Azure Function 中创建 QR 码需要哪些代码? 在 Azure Function 中,使用 IronBarcode 通过调用 BarcodeWriter.CreateBarcode 创建 QR 码。生成的 QR 码可以作为 HTTP 响应中的 JPEG 图像返回。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 1,979,979 | Version: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,979,979 查看许可证