Azure 上の .NET を使用して IronBarcode を実行できますか?
はい! IronBarcodeは、Azureサービス上にホストされた.NETアプリケーションでQR/バーコードの読み取りと書き込みに使用できます。 IronBarcodeはMVCウェブサイト、Azure Functions、その他多数のAzureプラットフォームで徹底的にテストされています。
前提条件
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上でIronBarcodeのパフォーマンスと安定性を制御する方法の一つはDockerを使用することです。 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このコードでは:
- "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でのアプリケーションデプロイ時に柔軟性を提供します。
Azureでバーコード処理パフォーマンスを向上させるためにDockerを使用できますか?
はい、Dockerを使用してAzureでのバーコード処理のパフォーマンスと安定性を高めることができます。DockerとのIronBarcode統合についての詳細なチュートリアルが利用可能です。
IronBarcodeライブラリはAzure Functionsをサポートしていますか?
IronBarcodeはAzure Functions V3およびV4をサポートしており、サーバーレス環境でのバーコード処理のシームレスな統合を可能にします。
Azure FunctionはIronBarcodeを使ってどのようにバーコードを処理しますか?
Azure Functionは、HTTPリクエストによってトリガされるときにIronBarcodeを使ってQRコードを生成するようにセットアップできます。それはメッセージを記録し、ライセンスキーを設定し、BarcodeWriter.CreateBarcodeを使用してQRコードを作成し、JPEGファイルとしてHTTPレスポンスで画像を返します。
Azure FunctionでQRコードを作成するために必要なコードは何ですか?
Azure Function内でIronBarcodeを使用してBarcodeWriter.CreateBarcodeを呼び出すことでQRコードを作成します。生成されたQRコードはHTTPレスポンスでJPEG画像として返すことができます。






