IronBarcode'u Azure'da .NET ile Çalıştırabilir miyim?
Evet! IronBarcode, Azure hizmetlerinde barındırılan .NET uygulamalarında QR/çubuk kodları okumak ve yazmak için kullanılabilir. IronBarcode, MVC web siteleri, Azure İşlevleri ve daha fazlası dahil olmak üzere birden fazla Azure platformunda kapsamlı bir şekilde test edilmiştir.
Ön Koşullar
1. Başlamak için IronBarcode'u Yükleyin
Öncelikle, NuGet web sitesi üzerinde NuGet paketini yükleyin.
Alternatif olarak, IronBarcode.dll de indirilebilir ve projenize eklenebilir.
Nasıl Rehberi
2. Performans ve Azure Katmanları
Kullanıcılarımızın çoğunun kullanım durumları için uygun olduğu için en azından Azure B1 hizmet planını kullanmanızı öneririz. Daha yüksek verimlilik gerektiren sistemler daha yüksek bir hizmet planı gerektirecektir.
3. Çerçeve Seçimi
.NET Standard, Core ve Framework projeleri IronBarcode ile uyumludur.
4. Azure'da Docker
Azure'da IronBarcode ile performans ve kararlılığı kontrol etme yeteneğini kazanmanın yollarından biri Docker kullanmaktır. IronBarcode'ı Azure ve Docker ile nasıl kullanacağınızı öğrenmek için şu eğitimi inceleyin.
5. Resmi Azure İşlev Desteği
IronBarcode, Azure İşlevleri V3 ve V4'ü şu anda desteklemektedir.
Çalışan Azure İşlev Kodu Örneği
Azure İşlevleri v3.3.1.0+'da test edilmiştir. İşte bir kod örneği:
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 ModuleBu kodda:
- "barcode" adıyla bir Azure İşlevi tanımlarız.
- İşlev bir HTTP isteğiyle tetiklenir ve işlendiğinde bir mesaj kaydeder.
- IronBarcode için lisans anahtarını belirliyoruz (
"Key"ile kendi lisans anahtarınızı değiştirin). - Bir QR kod barkodu
BarcodeWriter.CreateBarcodekullanılarak üretilir. - Çubuk kod görüntüsü JPEG formatına dönüştürülür ve HTTP yanıtına dahil edilir.
- Yanıt içeriği, dosya adı olarak geçerli tarih ve saatle bir indirilebilir ek olarak ayarlanır.
- Yanıt içerik türü, görüntü formatını belirtmek için "image/jpeg" olarak ayarlanır.
Sıkça Sorulan Sorular
IronBarcode, Azure'da .NET uygulamaları ile kullanılabilir mi?
Evet, IronBarcode, MVC web siteleri ve Azure İşlevleri gibi Azure hizmetlerinde barındırılan .NET uygulamalarında QR/barcode okumak ve yazmak için kullanılabilir.
IronBarcode için önerilen Azure hizmet planı nedir?
Çoğu kullanım senaryosu için en az Azure B1 hizmet planının kullanılması önerilir, daha fazla işlem hacmi gerektiren sistemler için daha yüksek hizmet planlarına ihtiyaç duyulur.
Hangi .NET çerçeveleri, Azure'da IronBarcode ile uyumludur?
IronBarcode, Azure'da çalışırken .NET Standard, Core ve Framework projeleri ile uyumludur.
Docker, Azure'da IronBarcode ile nasıl kullanılabilir?
Azure'da Docker kullanmak, IronBarcode dağıtırken performans ve kararlılığı kontrol etmeye yardımcı olabilir ve bir kılavuz mevcuttur.
Azure İşlevleri, resmi olarak IronBarcode tarafından destekleniyor mu?
Evet, IronBarcode, Azure İşlevleri V3 ve V4'ü destekler, böylece Azure serverless bilişimde barkod işlevselliklerini entegre edebilirsiniz.
IronBarcode ile bir Azure İşlevinde barkod nasıl oluşturulur ve kullanılır?
Bir Azure Function içerisinde, BarcodeWriter.CreateBarcode kullanarak bir barkod oluşturulabilir ve HTTP yanıtında bir görüntü dosyası olarak döndürülebilir.
Azure İşlevlerinde IronBarcode kullanarak barkod görüntüleri için hangi içerik türü ayarlanır?
Bir Azure İşlevinden IronBarcode kullanılarak döndürülen HTTP yanıtında barkod görüntüleri için içerik türü 'image/jpeg' olarak ayarlanır.
IronBarcode'u Azure İşlevleri içinde kullanmak için lisans anahtarı ayarlamak gerekli mi?
Evet, Azure İşlevlerinde IronBarcode'u etkinleştirmek ve herhangi bir sınırlandırmayı kaldırmak için lisans anahtarı ayarlamak gereklidir.
IronBarcode tarafından Azure İşlevlerinde oluşturulan barkodlar için hangi dosya formatı kullanılır?
IronBarcode tarafından Azure İşlevlerinde oluşturulan barkodlar, HTTP yanıtı için JPEG formatına dönüştürülür.
Azure İşlevlerinde IronBarcode kullanarak barkod görüntüleri için içerik başlıkları nasıl ayarlanır?
İçerik başlıkları, barkod görüntüsünü, dosya adı olarak mevcut tarih ve saat ile indirilebilir bir ek olarak tanımlamak için ayarlanır.
Curtis Chau, Bilgisayar Bilimleri alanında Lisans Derecesine (Carleton Üniversitesi) sahip ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirmeyle ilgileniyor. Sezgisel ve estetik açıdan hoş kullanıcı arayüzleri oluşturma tutkunu, Curtis modern çerçevelerle çalışmayı ve iyi yapılandırılmış, görsel olarak çekici kılavuzlar oluşturmayı seviyor.