我可以在 Azure 上運行 IronXL for .NET 嗎?

查克尼思·賓
查克尼思·賓
2022年2月28日
已更新 2024年10月20日
分享:
This article was translated from English: Does it need improvement?
Translated
View the article in English

是的。 IronXL 可以在 Azure 上用於生成 QR 和條碼於 C# 和 VB .NET 應用程式,同時也能從掃描圖像讀取條碼和 QR 碼。

IronXL 已在包括 MVC 網站、Azure 函式等多個 Azure 平台上進行了全面測試。


第一步

1. 安裝 IronXL 以開始使用

首先使用 NuGet 安裝:https://www.nuget.org/packages/IronXL.Excel

Install-Package IronXL.Excel

如何操作教程

2. 性能和 Azure 層次

我們建議 Azure B1 主機級別非常適合我們終端用戶的圖書館需求。 如果他們正在建立一個高吞吐量的系統,這可能需要升級。

3. 框架選擇

我們發現IronXL for Core和for Framework都可以在Azure上運作。 .NET Standard 應用程序似乎在速度和穩定性上具有輕微的性能優勢,但在進程中使用了更多內存。

Azure 免費層主機速度慢

Azure 免費和共享層級,以及消費計劃,不適合 QR 處理。 我們推薦使用 Azure B1 主機/高級方案,這也是我們自己使用的。

4. 在 Azure 上的 Docker

使用 IronXL 應用程式和功能於 Docker 容器中,是控制 Azure 性能的一種方法。

我們有一個針對 Linux 和 Windows 實例的全面IronXL Azure Docker 教程,建議您閱讀。

5. 官方 Azure 函數支持

IronXL 支援 Azure 功能 (Azure Functions V3)。 它目前尚未與V4測試,但已在我們的隊列中。

工作中的 Azure 函數代碼範例

在 Azure Functions v3.3.1.0+ 上進行了測試。 這是範例代碼

[FunctionName("excel")]
public static HttpResponseMessage Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
IronXL.License.LicenseKey = "Key";
var workBook = WorkBook.Load("test-wb.xlsx");
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(workBook.ToByteArray());
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"){ FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx" };
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
return result;
}
[FunctionName("excel")]
public static HttpResponseMessage Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
        ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
IronXL.License.LicenseKey = "Key";
var workBook = WorkBook.Load("test-wb.xlsx");
var result = new HttpResponseMessage(HttpStatusCode.OK);
result.Content = new ByteArrayContent(workBook.ToByteArray());
result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"){ FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx" };
result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
return result;
}
<FunctionName("excel")>
Public Shared 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.")
IronXL.License.LicenseKey = "Key"
Dim workBook = WorkBook.Load("test-wb.xlsx")
Dim result = New HttpResponseMessage(HttpStatusCode.OK)
result.Content = New ByteArrayContent(workBook.ToByteArray())
result.Content.Headers.ContentDisposition = New ContentDispositionHeaderValue("attachment") With {.FileName = $"{DateTime.Now:yyyyMMddmm}.xlsx"}
result.Content.Headers.ContentType = New MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
Return result
End Function
$vbLabelText   $csharpLabel
查克尼思·賓
軟體工程師
Chaknith 致力於 IronXL 和 IronBarcode。他在 C# 和 .NET 方面擁有豐富的專業知識,協助改進軟體並支持客戶。他從用戶互動中獲得的洞察力有助於提高產品、文檔和整體體驗。