首页 > 系统相关 >【Application Insights】使用Powershell命令向Application Insgihts发送测试数据

【Application Insights】使用Powershell命令向Application Insgihts发送测试数据

时间:2024-01-09 21:34:15浏览次数:23  
标签:ConnectionString System Application Net Powershell SecurityProtocolType Insights

问题描述

在昨天的文章中,介绍了 “【Application Insights】使用CURL命令向Application Insgihts发送测试数据 ”,今天则继续实验通过PowerShell命令来发送测试数据到Application Insights

【Application Insights】使用Powershell命令向Application Insgihts发送测试数据_System

 

问题解答

从参考文档中复制出 Powershell脚本,然后只需要修改 Application Insights的Connection String即可。

# Info: Provide either the connection string or ikey for your Application Insights resource
$ConnectionString = ""
$InstrumentationKey = ""
function ParseConnectionString {
param ([string]$ConnectionString)
  $Map = @{}
  foreach ($Part in $ConnectionString.Split(";")) {
     $KeyValue = $Part.Split("=")
     $Map.Add($KeyValue[0], $KeyValue[1])
  }
  return $Map
}
# If ikey is the only parameter supplied, we'll send telemetry to the global ingestion endpoint instead of regional endpoint found in connection strings
If (($InstrumentationKey) -and ("" -eq $ConnectionString)) {
$ConnectionString = "InstrumentationKey=$InstrumentationKey;IngestionEndpoint=https://dc.services.visualstudio.com/"
}
$map = ParseConnectionString($ConnectionString)
$url = $map["IngestionEndpoint"] + "v2/track"
$ikey = $map["InstrumentationKey"]
$lmUrl = $map["LiveEndpoint"]
$time = (Get-Date).ToUniversalTime().ToString("o")
$availabilityData = @"
{
  "data": {
        "baseData": {
            "ver": 2,
            "id": "SampleRunId",
            "name": "Microsoft Support Sample Webtest Result",
            "duration": "00.00:00:10",
            "success": true,
            "runLocation": "Region Name",
            "message": "Sample Webtest Result",
            "properties": {
                "Sample Property": "Sample Value"
                }
        },
        "baseType": "AvailabilityData"
  },
  "ver": 1,
  "name": "Microsoft.ApplicationInsights.Metric",
  "time": "$time",
  "sampleRate": 100,
  "iKey": "$ikey",
  "flags": 0
}
"@
# Uncomment one or more of the following lines to test client TLS/SSL protocols other than the machine default option
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::SSL3
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS11
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS12
# [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::TLS13
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest -Uri $url -Method POST -Body $availabilityData -UseBasicParsing

 

执行效果图:

【Application Insights】使用Powershell命令向Application Insgihts发送测试数据_System_02

 

 

 

参考资料

用于发送可用性测试结果的 PowerShell 脚本:https://learn.microsoft.com/zh-cn/troubleshoot/azure/azure-monitor/app-insights/investigate-missing-telemetry#powershell-script-send-availability-test-result

使用curl命令向Application Insights发送测试数据:https://www.cnblogs.com/lulight/p/17953251

 

【end】

 


当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

标签:ConnectionString,System,Application,Net,Powershell,SecurityProtocolType,Insights
From: https://blog.51cto.com/u_13773780/9165767

相关文章

  • 【Application Insights】使用CURL命令向Application Insgihts发送测试数据
    问题描述在使用AppService或者Kubernetes等服务时,需要收集一些日志数据并且发送到ApplicationInsights中,当使用SDK或者是服务自带的ApplicationInsights配置时遇见问题,有没有快速的调试方式能验证AppService是否与ApplicationInsights之间的连通性呢?问题解答可以使用CURL发送......
  • Spring的ApplicationContext核心分析
    跟着孙哥学Spring,b站:https://www.bilibili.com/video/BV185411477k/?spm_id_from=333.337.search-card.all.click1.AnnotationConfigApplicationContext执行过程publicstaticvoidmain(String[]args){AnnotationConfigApplicationContextctx=newAnnotationConfig......
  • Spring MVC 源码分析 - WebApplicationContext 容器的初始化
    随着 SpringBoot 和 SpringCloud 在许多中大型企业中被普及,可能你已经忘记当年经典的Servlet+SpringMVC的组合,是否还记得那个 web.xml 配置文件。在开始本文之前,请先抛开 SpringBoot 到一旁,回到从前,一起来看看Servlet是怎么和SpringMVC集成,怎么来初始化Sprin......
  • Microsoft 365 开发:如何通过PnP Powershell批量删除文件夹或文件等
    51CTOBlog地址:https://blog.51cto.com/u_13969817通常删除文件夹可以在UI界面操作比较方面,但是如果想快速的删除文件夹以及其childfolder,该如何操作呢?解决方案:本文将介绍如何使用PnPPowerShell脚本删除SharePoint文档库中的文件夹:第一步是通过运行cmdlet:ConnectPnPOnline来......
  • Microsoft 365开发:如何通过Graph Powershell推动密码过期邮件提醒
    51CTOBlog地址:https://blog.51cto.com/u_13969817密码过期提醒是一种安全措施,用于确保用户定期更改其密码,以减少密码被盗用的风险。当用户密码过期时,系统发送提醒通知,告知需要更改密码。这种提醒通常可以以电子邮件、系统通知的方式发送给用户,提醒中通常包含有关如何更改密码的提......
  • Microsoft 365开发:如何使用Powershell将单个或者多个用户邮箱转换为共享邮箱
    51CTOBlog地址:https://blog.51cto.com/u_13969817Office365是一个基于云的平台,提供了一套生产力工具,包括电子邮件、日历和文件共享。随着员工数量的增加和团队合作的需要,企业管理员经常会将个人邮箱转换为共享邮箱,其好处是:·      共享邮箱可以方便团队成员之间的邮件交......
  • Microsoft 365 新功能速递:如何用Powershell为SPO文件夹设置不同颜色
    51CTOBlog地址:https://blog.51cto.com/u_13969817微软最近推出了一项新功能,允许用户在SharePointOnline和OneDrive中使用预设的16种颜色为文件夹上色。此功能适用于新文件夹和现有文件夹。现在,用户可以使用不同的颜色自定义文件夹,以便更好地管理文件,比如:·      提供工作......
  • Random Forests in Computer Vision: Applications and Techniques
    1.背景介绍随机森林在计算机视觉领域的应用和技术随机森林(RandomForests)是一种机器学习方法,它通过构建多个决策树来进行预测和分类。这种方法在处理高维数据和非线性问题时具有很好的性能。在计算机视觉领域,随机森林已经被广泛应用于各种任务,例如图像分类、目标检测、对象识别等。......
  • Python Machine Learning Projects: Building RealWorld Applications
    1.背景介绍人工智能和机器学习技术在过去的几年里取得了巨大的进步,这使得许多实际应用成为可能。这本书《16.PythonMachineLearningProjects:BuildingReal-WorldApplications》旨在帮助读者理解这些实际应用,并提供有关如何使用Python编写机器学习代码的实践指南。本书的目......
  • GANs in the Wild: RealWorld Applications of Generative Adversarial Networks
    1.背景介绍生成对抗网络(GenerativeAdversarialNetworks,GANs)是一种深度学习算法,由伊戈尔·Goodfellow等人于2014年提出。这种算法通过两个神经网络来学习数据分布:一个生成器(Generator)和一个判别器(Discriminator)。生成器的目标是生成类似于训练数据的新数据,而判别器的目标是区分这......