Azure 上の .NET を使用して IronBarcode を実行できますか?
はい! IronBarcodeは、Azureサービス上にホストされた.NETアプリケーションでQR/バーコードの読み取りと書き込みに使用できます。 IronBarcodeはMVCウェブサイト、Azure Functions、その他多数のAzureプラットフォームで徹底的にテストされています。
前提条件
1. IronBarcodeをインストールして始めましょう
まず、NuGetのウェブサイトでNuGetパッケージをインストールします。
代替として、IronBarcode.dllをダウンロードし、プロジェクトに追加することもできます。
チュートリアル
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;
}
}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)> req As HttpRequest,
log As ILogger) As HttpResponseMessage
log.LogInformation("VB.NET 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 ModuleImports 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)> req As HttpRequest,
log As ILogger) As HttpResponseMessage
log.LogInformation("VB.NET 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」に設定されます。
よくある質問
IronBarcodeはAzure上の.NETアプリケーションで使用できますか?
はい、IronBarcodeは、MVCウェブサイトやAzure FunctionsなどのAzureサービスでホストされている.NETアプリケーションでQR/バーコードの読み取りおよび書き込みに使用できます。
IronBarcodeに推奨されるAzureサービスプランは何ですか?
ほとんどのケースでAzure B1サービスプランを使用することを推奨します。より多くのスループットを必要とするシステムには、高速なサービスプランが必要です。
.NETフレームワークでIronBarcodeがAzureで互換性のあるものはどれですか?
IronBarcodeは、Azure上で実行される.NET Standard、Core、およびFrameworkプロジェクトと互換性があります。
AzureでIronBarcodeはDockerとどのように使用できますか?
Azure上でDockerを使用すると、IronBarcodeのデプロイ時にパフォーマンスと安定性を制御できます。また、ガイダンス用のチュートリアルも利用可能です。
Azure FunctionsはIronBarcodeによって正式にサポートされていますか?
はい、IronBarcodeはAzure Functions V3およびV4をサポートしており、Azureサーバーレスコンピューティングにバーコード機能を統合できます。
IronBarcodeを使用して、Azure Functionでバーコードはどのように生成および使用されますか?
Azure Functionでは、BarcodeWriter.CreateBarcodeを使用してバーコードを生成し、HTTPレスポンスでイメージファイルとして返すことができます。
Azure FunctionsでIronBarcodeを使用した場合、バーコード画像のコンテンツタイプは何に設定されますか?
Azure FunctionsでIronBarcodeを使用してHTTPレスポンスから返されるバーコード画像のコンテンツタイプは'image/jpeg'に設定されます。
Azure FunctionsでIronBarcodeを使用する際にライセンスキーを設定する必要がありますか?
はい、Azure FunctionsでIronBarcodeを使用するにはライセンスキーを設定し、ライブラリをアクティブ化して制限を解除することが必要です。
Azure FunctionsでIronBarcodeによって生成されるバーコードのファイルフォーマットは何ですか?
Azure FunctionsでIronBarcodeによって生成されるバーコードは、HTTPレスポンス用にJPEGフォーマットに変換されます。
Azure FunctionsでIronBarcodeを使用した場合、バーコード画像のコンテンツヘッダーはどのように設定されますか?
コンテンツヘッダーは、現在の日付と時間をファイル名の一部としてダウンロード可能な添付ファイルとしてバーコード画像を定義するために設定されます。
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。