IronBarcode 開始使用 Azure 支援 Can I Run IronBarcode with .NET on Azure? Curtis Chau 更新日期:7月 24, 2025 Download IronBarcode NuGet 下載 DLL 下載 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 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 等。 class="main-content__segment-title">先決條件 1. 安裝 IronBarcode 開始使用 首先,在 NuGet 網站上安裝 NuGet 套件。 Install-Package BarCode As an alternative, the IronBarcode.dll could also be downloaded and added to your project. class="main-content__segment-title">教程指南 2. 性能和 Azure 等級 我們建議至少使用 Azure B1 服務計劃,因為它適合我們大多數用戶的使用案例。 需要更高吞吐量的系統將需要更高的服務計劃。 3. 框架選擇 .NET Standard、Core 和 Framework 專案均與 IronBarcode 兼容。 4. Azure 上的 Docker 在 Azure 上使用 IronBarcode 控制性能和穩定性的一種方法是使用 Docker。 要了解如何在 Azure 和 Docker 中使用 IronBarcode,請查看此教程。 5. 官方 Azure Functions 支援 IronBarcode 目前支援 Azure Functions V3 和 V4。 工作中的 Azure Functions 代碼範例 已在 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 函數如何使用 IronBarcode 來處理條碼? 可以使用 IronBarcode 設定 Azure 函數,使其在收到 HTTP 請求時產生二維碼。此函數會記錄一則訊息,設定許可證金鑰,使用BarcodeWriter.CreateBarcode建立二維碼,並將影像作為 JPEG 檔案在 HTTP 回應中傳回。 在 Azure 函數中建立二維碼需要什麼程式碼? 在 Azure 函數中,可以使用 IronBarcode 透過在函數內部呼叫BarcodeWriter.CreateBarcode來建立二維碼。產生的二維碼隨後可以作為 JPEG 影像在 HTTP 回應中傳回。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 1,935,276 | 版本: 2025.11 剛剛發布 免費 NuGet 下載 總下載量:1,935,276 查看許可證