Azure 学习总结

文章目录

    • [1. Azure Function](#1. Azure Function)
      • [1.1 Azure Function 概念](#1.1 Azure Function 概念)
      • [1.2 Azure Function 实现原理](#1.2 Azure Function 实现原理)
      • [1.3 Azure Function 本地调试](#1.3 Azure Function 本地调试)
      • [1.4 Azure Function 云部署](#1.4 Azure Function 云部署)
    • [2. Azure API Managment 概念 以及使用](#2. Azure API Managment 概念 以及使用)
      • [2.1 Azure API 概念](#2.1 Azure API 概念)
      • [2.2 Azure API 基本使用](#2.2 Azure API 基本使用)
    • [3. Service Bus 应用场景及相关特性](#3. Service Bus 应用场景及相关特性)
      • [3.1 Service Bus 基本简介与特性](#3.1 Service Bus 基本简介与特性)
      • [3.2 Service Bus 消息队列](#3.2 Service Bus 消息队列)
    • [4. Azure Monitor](#4. Azure Monitor)
      • [4.1 Azure Monitor 基本介绍](#4.1 Azure Monitor 基本介绍)
      • [4.2 Azure Monitor 观测性及查询](#4.2 Azure Monitor 观测性及查询)

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 概念

  1. Azure API 管理是由API网关、管理平面以及开发人员组成的,API管理提供Azure当中组件的相关API管理的使用

2.2 Azure API 基本使用

  1. 通过Azure 创建第一个 Azure API实例
  2. 在API管理当中创建测试API,并设置其返回Json{"word" : "beautiful"}
  3. 启用响应式模拟,测试模拟API

效果图:

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

Azure Service Bus 服务

3.1 Service Bus 基本简介与特性

Service Bus简介

Service Bus 队列

  1. Service Bus. 企业消息服务代理,其中有消息队列和发布订阅主题两种。
  2. Service Bus 队列类似于一个中间管理服务,将所有发送方的请求暂时以队列FIFO的方式暂存在中间通道,消息使用方按顺序从此中间站当中获取相应的服务.

3.2 Service Bus 消息队列

  1. 首先需要在Azure当中创建 Service Bus命名空间(可以为队列以及主题提供范围容器)
  2. 在对应Service Bus 当中创建队列
  3. 利用Visual Studio 测试队列消息的接受与发送

消息队列创建

消息队列代码

csharp 复制代码
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

4.1 Azure Monitor 基本介绍

Azure Monitor 全面的数据监视解决,将数据收集到数据平台,数据平台存储监视数据。通过一些见解、可视化、和分析数据工具显示。

4.2 Azure Monitor 观测性及查询

  1. Azure Monitor 是可观测性工具,通过进入相应对应的Azure资源当中,点击侧面的监视栏即可观测Azure Monitor 相关监视的一些可视化工具.
相关推荐
恰薯条的屑海鸥7 小时前
零基础在实践中学习网络安全-皮卡丘靶场(第十六期-SSRF模块)
数据库·学习·安全·web安全·渗透测试·网络安全学习
喜欢吃燃面8 小时前
C++刷题:日期模拟(1)
c++·学习·算法
2301_797604249 小时前
学习记录:DAY32
学习
蓝婷儿9 小时前
6个月Python学习计划 Day 16 - 面向对象编程(OOP)基础
开发语言·python·学习
叶子2024229 小时前
学习使用YOLO的predict函数使用
人工智能·学习·yolo
jackson凌9 小时前
【Java学习笔记】SringBuffer类(重点)
java·笔记·学习
黑客老李11 小时前
JavaSec | SpringAOP 链学习分析
java·运维·服务器·开发语言·学习·apache·memcached
海的诗篇_12 小时前
移除元素-JavaScript【算法学习day.04】
javascript·学习·算法
傍晚冰川12 小时前
FreeRTOS任务调度过程vTaskStartScheduler()&任务设计和划分
开发语言·笔记·stm32·单片机·嵌入式硬件·学习
月初,13 小时前
MongoDB学习和应用(高效的非关系型数据库)
学习·mongodb·nosql