0
点赞
收藏
分享

微信扫一扫

EasyExcel多线程批量导出数据,动态表头,静态资源访问

夕阳孤草 2023-12-29 阅读 12

文章目录

1. Azure Function

参考资料:Microsoft Azure
参考资料(快速入门):使用Visual studio在Azure中创建第一个c#函数
参考资料:AZ-900

1.1 Azure Function 概念

在这里插入图片描述

Azure Function:
1. 可以直接编写重要代码,不需要关心基础结构的维护,可以直接上传到云服务当中.

1.2 Azure Function 实现原理

1. 利用提供的触发器和绑定进行连接服务,例如绑定的Web API(HTTP触发器服务),当发生HTTP请求
时,Azure 云服务就可以对这个请求做出响应

代码分析:
在这里插入图片描述
效果图:
在这里插入图片描述

1.3 Azure Function 本地调试

### 本地调试
1.  创建Azure Function项目(c#类),之后将其进行运行即可.

在这里插入图片描述

1.4 Azure Function 云部署

1. 本地测试代码通过
2. Azure本地资源当中创建函数应用
3. 将Azure Function本地代码上传到Azure当中对应的函数应用组当中
 /api/HttpExample?name=Functions 追加至url地址之后

效果图:
在这里插入图片描述

2. Azure API Managment 概念 以及使用

参考资料:Azure API管理文档

2.1 Azure API 概念

在这里插入图片描述

2.2 Azure API 基本使用

效果图:
在这里插入图片描述

3. Service Bus 应用场景及相关特性

Azure Service Bus 服务

3.1 Service Bus 基本简介与特性

Service Bus简介
在这里插入图片描述
Service Bus 队列
在这里插入图片描述

3.2 Service Bus 消息队列

消息队列创建
在这里插入图片描述

消息队列代码

using Azure.Messaging.ServiceBus;
using Azure.Identity;

// service bus 队列,用于发送以及接收消息
ServiceBusClient client;

// the sender used to publish messages to the queue
ServiceBusSender sender;

// number of messages to be sent to the queue
const int numOfMessages = 3;

// The Service Bus client types are safe to cache and use as a singleton for the lifetime
// of the application, which is best practice when messages are being published or read
// regularly.
//
// Set the transport type to AmqpWebSockets so that the ServiceBusClient uses the port 443. 
// If you use the default AmqpTcp, ensure that ports 5671 and 5672 are open.
var clientOptions = new ServiceBusClientOptions
{
    TransportType = ServiceBusTransportType.AmqpWebSockets
};
// ServiceBus 的命名空间以及队列名称,以及默认的登录用户权限信息
client = new ServiceBusClient(
    "ServiceBusExampleTestZhangyunyi.servicebus.windows.net", // 
    new DefaultAzureCredential(),
    clientOptions);
sender = client.CreateSender("myqueue");

// create a batch 
using ServiceBusMessageBatch messageBatch = await sender.CreateMessageBatchAsync();

for (int i = 1; i <= numOfMessages; i++)
{
    // try adding a message to the batch
    if (!messageBatch.TryAddMessage(new ServiceBusMessage($"Message {i}")))
    {
        // if it is too large for the batch
        throw new Exception($"The message {i} is too large to fit in the batch.");
    }
}

try
{
    // Use the producer client to send the batch of messages to the Service Bus queue
    await sender.SendMessagesAsync(messageBatch);
    Console.WriteLine($"A batch of {numOfMessages} messages has been published to the queue.");
}
finally
{
    // Calling DisposeAsync on client types is required to ensure that network
    // resources and other unmanaged objects are properly cleaned up.
    await sender.DisposeAsync();
    await client.DisposeAsync();
}

Console.WriteLine("Press any key to end the application");
Console.ReadKey();

4. Azure Monitor相关内容,了解可观测性相关配置与查询操作

举报

相关推荐

0 条评论