【Azure Developer】使用REST API获取Activity Logs、传入Data Lake的数据格式问题
问题一:. 如何在用REST API获取活动日志时,控制输出的项?
【答】参考REST API对于获取活动日志的说明接口,在参数是$filter和$select中可以分别控制过滤条件和输出项
GET https://management.chinacloudapi.cn/subscriptions/{subscriptionId}/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter={$filter}&$select={$select}
注:management.chinacloudapi.cn为中国区Azure的管理终结点,management.azure.com为全球Azure的管理终结点
URI Parameters
| Name | Description |
|---|---|
|
$filter
|
Reduces the set of data collected. The $filter argument is very restricted and allows only the following patterns. $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceGroupName eq 'resourceGroupName'. $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceUri eq 'resourceURI'. $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z'. $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and resourceProvider eq 'resourceProviderName'. $filter=eventTimestamp ge '2014-07-16T04:36:37.6407898Z' and eventTimestamp le '2014-07-20T04:36:37.6407898Z' and correlationId eq 'correlationID'. |
|
$select
|
Used to fetch events with only the given properties. Possible values are: authorization, claims, correlationId, description, eventDataId, eventName, eventTimestamp, httpRequest, level, operationId, operationName, properties, resourceGroupName, resourceProviderName, resourceId, status, submissionTimestamp, subStatus, subscriptionId |
在Filter和select可以配置的每一项说明,请查看文末的附录一。
问题二:是否可以往Data Lake中注入Json格式文件?
【答】根据官方文档示例,如果使用Databricks进行(SQL查询语句)进行数据分析,是支持Json格式的数据,示例中使用的Json格式如下图所示:

参考使用 Databricks 分析数据一文: https://docs.azure.cn/zh-cn/storage/blobs/data-lake-storage-quickstart-create-databricks-account#ingest-sample-data
问题三:如何用C#向Data Lake中插入数据文件?
【答】可以,需要先安装 Azure.Storage.Files.DataLake NuGet 包。然后添加如下引用
using Azure.Storage.Files.DataLake;
using Azure.Storage.Files.DataLake.Models;
using Azure.Storage;
using System.IO;
using Azure;
将文件上传到目录,则参考以下代码即可:
- 通过创建 DataLakeFileClient 类的实例,在目标目录中创建文件引用。
- 通过调用 DataLakeFileClient.AppendAsync 方法上传文件。
- 确保通过调用 DataLakeFileClient.FlushAsync 方法完成上传。
public async Task UploadFile(DataLakeFileSystemClient fileSystemClient)
{
DataLakeDirectoryClient directoryClient =
fileSystemClient.GetDirectoryClient("my-directory"); DataLakeFileClient fileClient = await directoryClient.CreateFileAsync("uploaded-file.txt"); FileStream fileStream =
File.OpenRead("C:\\file-to-upload.txt"); long fileSize = fileStream.Length; await fileClient.AppendAsync(fileStream, offset: 0); await fileClient.FlushAsync(position: fileSize); }
完整实例参考使用 .NET 管理 Azure Data Lake Storage Gen2:https://docs.azure.cn/zh-cn/storage/blobs/data-lake-storage-directory-file-acl-dotnet#upload-a-file-to-a-directory
附录一:在$Filter和$select可配置的选择项的EventData属性
The Azure event log entries are of type EventData
| Name | Type | Description |
|---|---|---|
| authorization |
The sender authorization information. |
|
| caller |
|
the email address of the user who has performed the operation, the UPN claim or SPN claim based on availability. |
| category |
the event category. |
|
| claims |
|
key value pairs to identify ARM permissions. |
| correlationId |
|
the correlation Id, usually a GUID in the string format. The correlation Id is shared among the events that belong to the same uber operation. |
| description |
|
the description of the event. |
| eventDataId |
|
the event data Id. This is a unique identifier for an event. |
| eventName |
the event name. This value should not be confused with OperationName. For practical purposes, OperationName might be more appealing to end users. |
|
| eventTimestamp |
|
the timestamp of when the event was generated by the Azure service processing the request corresponding the event. It in ISO 8601 format. |
| httpRequest |
the HTTP request info. Usually includes the 'clientRequestId', 'clientIpAddress' (IP address of the user who initiated the event) and 'method' (HTTP method e.g. PUT). |
|
| id |
|
the Id of this event as required by ARM for RBAC. It contains the EventDataID and a timestamp information. |
| level |
the event level |
|
| operationId |
|
It is usually a GUID shared among the events corresponding to single operation. This value should not be confused with EventName. |
| operationName |
the operation name. |
|
| properties |
|
the set of <Key, Value> pairs (usually a Dictionary<String, String>) that includes details about the event. |
| resourceGroupName |
|
the resource group name of the impacted resource. |
| resourceId |
|
the resource uri that uniquely identifies the resource that caused this event. |
| resourceProviderName |
the resource provider name of the impacted resource. |
|
| resourceType |
the resource type |
|
| status |
a string describing the status of the operation. Some typical values are: Started, In progress, Succeeded, Failed, Resolved. |
|
| subStatus |
the event sub status. Most of the time, when included, this captures the HTTP status code of the REST call. Common values are: OK (HTTP Status Code: 200), Created (HTTP Status Code: 201), Accepted (HTTP Status Code: 202), No Content (HTTP Status Code: 204), Bad Request(HTTP Status Code: 400), Not Found (HTTP Status Code: 404), Conflict (HTTP Status Code: 409), Internal Server Error (HTTP Status Code: 500), Service Unavailable (HTTP Status Code:503), Gateway Timeout (HTTP Status Code: 504) |
|
| submissionTimestamp |
|
the timestamp of when the event became available for querying via this API. It is in ISO 8601 format. This value should not be confused eventTimestamp. As there might be a delay between the occurrence time of the event, and the time that the event is submitted to the Azure logging infrastructure. |
| subscriptionId |
|
the Azure subscription Id usually a GUID. |
| tenantId |
|
the Azure tenant Id |
【Azure Developer】使用REST API获取Activity Logs、传入Data Lake的数据格式问题的更多相关文章
- 【Azure Developer】使用Postman获取Azure AD中注册应用程序的授权Token,及为Azure REST API设置Authorization
Azure Active Directory (Azure AD) is Microsoft's cloud-based identity and access management service, ...
- 【Azure Developer】使用 CURL 获取 Key Vault 中 Secrets 中的值
问题描述 在使用CURL通过REST API获取Azure Key Vaualt的Secrets值,提示Missing Token, 问如何来生成正确的Token呢? # curl 命令 curl - ...
- 【Azure Developer】使用Microsoft Graph API 批量创建用户,先后遇见的三个错误及解决办法
问题描述 在先前的一篇博文中,介绍了如何使用Microsoft Graph API来创建Azure AD用户(博文参考:[Azure Developer]使用Microsoft Graph API 如 ...
- 【Azure Developer】解决Azure Key Vault管理Storage的示例代码在中国区Azure遇见的各种认证/授权问题 - C# Example Code
问题描述 使用Azure密钥保管库(Key Vault)来托管存储账号(Storage Account)密钥的示例中,从Github中下载的示例代码在中国区Azure运行时候会遇见各种认证和授权问题, ...
- Databricks 第8篇:把Azure Data Lake Storage Gen2 (ADLS Gen 2)挂载到DBFS
DBFS使用dbutils实现存储服务的装载(mount.挂载),用户可以把Azure Data Lake Storage Gen2和Azure Blob Storage 账户装载到DBFS中.mou ...
- 构建企业级数据湖?Azure Data Lake Storage Gen2实战体验(下)
相较传统的重量级OLAP数据仓库,“数据湖”以其数据体量大.综合成本低.支持非结构化数据.查询灵活多变等特点,受到越来越多企业的青睐,逐渐成为了现代数据平台的核心和架构范式. 作为微软Azure上最新 ...
- Azure Data Lake Storage Gen2实战体验
相较传统的重量级OLAP数据仓库,“数据湖”以其数据体量大.综合成本低.支持非结构化数据.查询灵活多变等特点,受到越来越多企业的青睐,逐渐成为了现代数据平台的核心和架构范式. 作为微软Azure上最新 ...
- 【Azure Developer】使用 Microsoft Graph API 获取 AAD User 操作示例
问题描述 查看官方文档" Get a user " , 产生了一个操作示例的想法,在中国区Azure环境中,演示如何获取AAD User信息. 问题解答 使用Microsoft G ...
- 【Azure Developer】使用 Microsoft Authentication Libraries (MSAL) 如何来获取Token呢 (通过用户名和密码方式获取Access Token)
问题描述 在上一篇博文<[Azure Developer]使用 adal4j(Azure Active Directory authentication library for Java)如何来 ...
- 【Azure Developer】【Python 】使用 azure.identity 和 azure.common.credentials 获取Azure AD的Access Token的两种方式
问题描述 使用Python代码,展示如何从Azure AD 中获取目标资源的 Access Token. 如要了解如何从AAD中获取 client id,client secret,tenant id ...
随机推荐
- 大数据面试题集锦-Hadoop面试题(二)-HDFS
你准备好面试了吗?这里有一些面试中可能会问到的问题以及相对应的答案.如果你需要更多的面试经验和面试题,关注一下"张飞的猪大数据分享"吧,公众号会不定时的分享相关的知识和资料. 目录 ...
- IQueryable和IEnumerable学习
IQueryable和IEnumerable区别 开始了解IQueryable和IEnumerable前,我们先看一下源码 由上面的图片可以得知IQueryable接口继承自IEnumerable接口 ...
- 窗口管理器 dwm安装
上一篇博文中,已经完成了archlinux的安装,但是进去仅仅是一个冰冷冷的交互式命令窗口.没有图像,也无法打开浏览器.离日常使用还差的很远,接下来首先需要做的就是安装桌面环境.这里我不打算使用诸如g ...
- c++基础之表达式
这次接着更新<c++ primer> 这本书的读书笔记,上一篇博文更新到了书中的第三章,本次将记录书中的第四章--表达式 左值与右值 在理解表达式之前需要先理解c++中左值和右值的概念. ...
- ElasticSearch安装、插件介绍及Kibana的安装与使用详解
ElasticSearch安装.插件介绍及Kibana的安装与使用详解 1.安装 ElasticSearch 1.1 安装 JDK 环境 因为 ElasticSearch 是用 Java 语言编写的, ...
- python处理Excel实现自动化办公教学(含实战)【一】
相关文章: python处理Excel实现自动化办公教学(含实战)[一] python处理Excel实现自动化办公教学(含实战)[二] python处理Excel实现自动化办公教学(数据筛选.公式操作 ...
- 【五】gym搭建自己的环境之寻宝游戏,详细定义自己myenv.py文件以及算法实现
相关文章: 相关文章: [一]gym环境安装以及安装遇到的错误解决 [二]gym初次入门一学就会-简明教程 [三]gym简单画图 [四]gym搭建自己的环境,全网最详细版本,3分钟你就学会了! [五] ...
- C++ Boost库 操作日期与时间
Boost库中默认针对日期与时间的操作库分为,timer,progress_timer,date_time这几类,如下是一些常用的使用方法总结. timer库 #include <iostrea ...
- 基于volcano实现节点真实负载感知调度
本文分享自华为云社区<基于volcano实现节点真实负载感知调度>,作者: 可以交个朋友. 背景 默认调度器调度器视某个节点的空闲可调度资源=节点可分配资源 - SUM(节点上已调度Pod ...
- h5st 4.3版本代码研究
背景介绍 最近比较悠闲,于是没事研究了一下某东的h5st代码,2024年新鲜出炉的前端加密代码: 最大的惊喜并不是算法的复杂,在逆向破解代码的过程中,对js加密混淆有了新的认识: 于是心血来潮,回到这 ...