Merge pull request #6 from macrogreg/dev

Merge latest changes
This commit is contained in:
MacroGreg 2020-05-19 01:34:34 -07:00 коммит произвёл GitHub
Родитель 104b94e93e 6cd3500271
Коммит 9ea18928c2
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
76 изменённых файлов: 825 добавлений и 21 удалений

Просмотреть файл

@ -44,6 +44,12 @@ namespace Microsoft.Azure.AvailabilityMonitoring.Extensions
}
}
// If we wanted to only include DependencyTelemetry, we would do it something like this:
// if (false == (telemetryItem is DependencyTelemetry))
//{
// return;
//}
Activity activity = Activity.Current;
if (TryPopulateContextFromActivity(telemetryItem, activity))
{

Просмотреть файл

@ -126,16 +126,15 @@ namespace Microsoft.Azure.AvailabilityMonitoring
_activitySpanId = Format.AvailabilityTest.SpanId(_activitySpan);
_distributedOperationId = _activitySpan.RootId;
//_activitySpan.
// Start the timer:
_startTime = DateTimeOffset.Now;
_log?.LogInformation($"{nameof(AvailabilityTestScope)}.{nameof(Start)} finished:"
+ " {{TestDisplayName=\"{TestDisplayName}\", LocationDisplayName=\"{LocationDisplayName}\", LocationId=\"{LocationId}\","
+ " SpanId=\"{SpanId}\", StartTime=\"{StartTime}\", OperationName=\"{OperationName}\"}}",
+ " SpanId=\"{SpanId}\", SpanIdFormat=\"{SpanIdFormat}\", StartTime=\"{StartTime}\", OperationName=\"{OperationName}\"}}",
TestDisplayName, LocationDisplayName, LocationId,
_activitySpanId, _startTime.ToString("o"), _activitySpanOperationName);
_activitySpanId, _activitySpan.IdFormat, _startTime.ToString("o"), _activitySpanOperationName);
}
}

Просмотреть файл

@ -5,13 +5,19 @@ VisualStudioVersion = 16.0.29519.181
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring", "AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj", "{13CD7C8A-600D-4F5B-84B4-40D2575E21F2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-DemoConsole", "AvailabilityMonitoring-Extension-DemoConsole\AvailabilityMonitoring-Extension-DemoConsole.csproj", "{0AA499F5-F903-4FAC-BF3B-EA75D6735167}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-DemoConsole", "Demos\AvailabilityMonitoring-Extension-DemoConsole\AvailabilityMonitoring-Extension-DemoConsole.csproj", "{0AA499F5-F903-4FAC-BF3B-EA75D6735167}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-DemoFunction", "AvailabilityMonitoring-Extension-DemoFunction\AvailabilityMonitoring-Extension-DemoFunction.csproj", "{32B33932-2F92-4236-A286-3A085781E11C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-DemoFunction", "Demos\AvailabilityMonitoring-Extension-DemoFunction\AvailabilityMonitoring-Extension-DemoFunction.csproj", "{32B33932-2F92-4236-A286-3A085781E11C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-MonitoredAppSample", "AvailabilityMonitoring-Extension-MonitoredAppSample\AvailabilityMonitoring-Extension-MonitoredAppSample.csproj", "{D52BC15A-37C0-45A5-94C5-1AC546785846}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvailabilityMonitoring-Extension-MonitoredAppSample", "Demos\AvailabilityMonitoring-Extension-MonitoredAppSample\AvailabilityMonitoring-Extension-MonitoredAppSample.csproj", "{D52BC15A-37C0-45A5-94C5-1AC546785846}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlainSimplePrototype", "PlainSimplePrototype\PlainSimplePrototype.csproj", "{9275BF08-E979-44A3-96C1-7202CB1A52D0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlainSimplePrototype", "PlainSimplePrototype\PlainSimplePrototype.csproj", "{9275BF08-E979-44A3-96C1-7202CB1A52D0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Demos", "Demos", "{D87E0179-8A11-477C-9AA6-6ACD0F155BC5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvailabilityMonitoring-Extension-MonitoredFuncSample", "Demos\AvailabilityMonitoring-Extension-MonitoredFuncSample\AvailabilityMonitoring-Extension-MonitoredFuncSample.csproj", "{2DCF0A71-BE90-4942-B152-68AD127FE4E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AvailabilityMonitoring-Extension-SimpleScenarioCatFunction", "Demos\AvailabilityMonitoring-Extension-SimpleScenarioCatFunction\AvailabilityMonitoring-Extension-SimpleScenarioCatFunction.csproj", "{4DAE7E06-63DB-42D1-BDC7-04D90BB72961}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -39,10 +45,25 @@ Global
{9275BF08-E979-44A3-96C1-7202CB1A52D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9275BF08-E979-44A3-96C1-7202CB1A52D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9275BF08-E979-44A3-96C1-7202CB1A52D0}.Release|Any CPU.Build.0 = Release|Any CPU
{2DCF0A71-BE90-4942-B152-68AD127FE4E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DCF0A71-BE90-4942-B152-68AD127FE4E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DCF0A71-BE90-4942-B152-68AD127FE4E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DCF0A71-BE90-4942-B152-68AD127FE4E5}.Release|Any CPU.Build.0 = Release|Any CPU
{4DAE7E06-63DB-42D1-BDC7-04D90BB72961}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4DAE7E06-63DB-42D1-BDC7-04D90BB72961}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DAE7E06-63DB-42D1-BDC7-04D90BB72961}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DAE7E06-63DB-42D1-BDC7-04D90BB72961}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{0AA499F5-F903-4FAC-BF3B-EA75D6735167} = {D87E0179-8A11-477C-9AA6-6ACD0F155BC5}
{32B33932-2F92-4236-A286-3A085781E11C} = {D87E0179-8A11-477C-9AA6-6ACD0F155BC5}
{D52BC15A-37C0-45A5-94C5-1AC546785846} = {D87E0179-8A11-477C-9AA6-6ACD0F155BC5}
{2DCF0A71-BE90-4942-B152-68AD127FE4E5} = {D87E0179-8A11-477C-9AA6-6ACD0F155BC5}
{4DAE7E06-63DB-42D1-BDC7-04D90BB72961} = {D87E0179-8A11-477C-9AA6-6ACD0F155BC5}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B62196E4-D124-4879-B726-71519C486A1A}
EndGlobalSection

Просмотреть файл

@ -14,7 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj" />
<ProjectReference Include="..\..\AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj" />
</ItemGroup>
<ItemGroup>

Просмотреть файл

@ -8,7 +8,7 @@
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj" />
<ProjectReference Include="..\..\AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">

Просмотреть файл

@ -15,7 +15,7 @@ namespace AvailabilityMonitoring_Extension_DemoFunction
[FunctionName("CatDemo-SimpleBinding")]
[return: AvailabilityTestResult]
public static async Task<bool> Run(
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo _,
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo notUsed,
ILogger log)
{
log.LogInformation($"[CatDemo-SimpleBinding] Run(..): C# Coded Availability Test Function executed at: {DateTime.Now}."
@ -41,7 +41,7 @@ namespace AvailabilityMonitoring_Extension_DemoFunction
[FunctionName("CatDemo-ExplicitlySpecifyConfig")]
[return: AvailabilityTestResult(TestDisplayName = "Validation Test 1", LocationDisplayName = "Validation Location 1", LocationId = "val-loc-1")]
public static async Task<AvailabilityTelemetry> Run(
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo _,
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo notUsed,
//[TimerTrigger("*/5 * * * * *")] TimerInfo timerInfo,
[AvailabilityTestInfo] AvailabilityTestInfo testInfo,
ILogger log)
@ -77,7 +77,7 @@ namespace AvailabilityMonitoring_Extension_DemoFunction
[FunctionName("CatDemo-ThrowsException")]
[return: AvailabilityTestResult]
public static bool RunWithException(
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo _,
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo notUsed,
//[TimerTrigger("*/5 * * * * *")] TimerInfo timerInfo,
ILogger log)
{
@ -91,7 +91,7 @@ namespace AvailabilityMonitoring_Extension_DemoFunction
[FunctionName("CatDemo-TimeoutError")]
[return: AvailabilityTestResult]
public static async Task<bool> RunWithTimeout(
[TimerTrigger(AvailabilityTestInterval.Minutes05)] TimerInfo _,
[TimerTrigger(AvailabilityTestInterval.Minutes05)] TimerInfo notUsed,
ILogger log)
{
log.LogInformation($"[CatDemo-PlainSimplePrototype-ShouldTimeout] RunWithTimeout(..): C# Coded Availability Test Function executed at: {DateTime.Now}."

Просмотреть файл

@ -16,12 +16,15 @@ namespace AvailabilityMonitoring_Extension_MonitoredAppSample.Controllers
[ApiController]
public class TimeController : ControllerBase
{
public const string Version = "4";
// GET: api/Time
[HttpGet]
public async Task<MonitoredPageViewModel> GetAsync()
{
var model = new MonitoredPageViewModel()
{
Version = TimeController.Version,
PublicTime = await GetRemoteTimeInfoAsync(),
LocalTime = GetLocalTimeInfo(),
FunctionTime = await GetFunctionTimeInfoAsync(),
@ -67,7 +70,7 @@ namespace AvailabilityMonitoring_Extension_MonitoredAppSample.Controllers
using (var http = new HttpClient())
{
using (HttpResponseMessage response = await http.GetAsync("https://gregp-cat-test11.azurewebsites.net/api/TimeServer"))
using (HttpResponseMessage response = await http.GetAsync("https://availabilitymonitoring-extension-monitoredfuncsample.azurewebsites.net/api/TimeServer"))
{
response.EnsureSuccessStatusCode();
responseContent = await response.Content.ReadAsStringAsync();

Просмотреть файл

@ -5,6 +5,8 @@ namespace AvailabilityMonitoring_Extension_MonitoredAppSample.Models
{
public class MonitoredPageViewModel
{
public string Version { get; set; }
public class TimeInfo
{
public DateTimeOffset UtcTime { get; set; }
@ -20,7 +22,5 @@ namespace AvailabilityMonitoring_Extension_MonitoredAppSample.Models
public TimeInfo FunctionTime { get; set; }
public IList<KeyValuePair<string, string>> LocalEnvironment { get; set; }
}
}

Просмотреть файл

@ -3,6 +3,6 @@
}
<div class="text-center">
<h1 class="display-4">Welcome, Sashechka-Busechka</h1>
<h1 class="display-4">Welcome to AvailabilityMonitoring-Extension-MonitoredAppSample</h1>
<p>Azure Monitor rocks!</p>
</div>

Просмотреть файл

@ -14,7 +14,7 @@
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">AvailabilityMonitoring-Extension: Monitored App Sample</a>
<b>(App Version Id: 2)</b>
<b>(App Version Id: @AvailabilityMonitoring_Extension_MonitoredAppSample.Controllers.TimeController.Version)</b>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

Просмотреть файл

@ -8,6 +8,6 @@
},
"AllowedHosts": "*",
"ApplicationInsights": {
"InstrumentationKey": "6e204f56-fd43-4c08-afda-cd716bf41d49"
"InstrumentationKey": "f6fc7bc1-8ed0-473e-b93d-c05654da9fff"
}
}

Просмотреть файл

До

Ширина:  |  Высота:  |  Размер: 31 KiB

После

Ширина:  |  Высота:  |  Размер: 31 KiB

Просмотреть файл

@ -0,0 +1,264 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# Azure Functions localsettings file
local.settings.json
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

Просмотреть файл

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<RootNamespace>AvailabilityMonitoring_Extension_MonitoredFuncSample</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -26,7 +26,7 @@ namespace AvailabilityMonitoring_Extension_DemoFunction
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
log.LogInformation($"C# Http trigger function executed at: {DateTime.Now}");
log.LogInformation("Function \"TimeServer\" was invoked.");
TimeInfo timeInfo = GetLocalTimeInfo();

Просмотреть файл

@ -0,0 +1,14 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"logLevel": {
"default": "Trace"
}
}
}

Просмотреть файл

@ -0,0 +1,264 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# Azure Functions localsettings file
local.settings.json
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc

Просмотреть файл

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<RootNamespace>AvailabilityMonitoring_Extension_SimpleScenarioCatFunction</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AvailabilityMonitoring-Extension\Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,177 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.AvailabilityMonitoring;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.AvailabilityMonitoring;
using Microsoft.Extensions.Logging;
namespace AvailabilityMonitoring_Extension_DemoFunction
{
// This is an example for how the scaffolded code generated by selecting a Function template might look like.
// Template parameters are assigned in the body of Run(..).
// The user is then expected to modify the ValidateResponseAsync(..) method.
// Of course, they can modify more, bit focussing on should be the success pit.
// In this example we let the user copletely valudate the response, but we ca use template paramaters for that too.
public static class CatMonitoredApiIsAvailable
{
[FunctionName("Monitored-API-is-available")]
[return: AvailabilityTestResult]
public static async Task<bool> Run(
[TimerTrigger(AvailabilityTestInterval.Minute01)] TimerInfo notUsed,
ILogger log)
{
// User-specified test parameters:
string monitoredApiUrl = "http://availabilitymonitoring-extension-monitoredappsample02.azurewebsites.net/api/Time?source=CatMonitoredApiIsAvailable";
HttpMethod httpMethod = HttpMethod.Get;
KeyValuePair<string, string>[] headers = new KeyValuePair<string, string>[] {
};
string payload = null;
TimeSpan overallTimeout = TimeSpan.FromSeconds(30);
// Needs to be set for the result:
bool isAvailabilityTestSuccessful;
// Initialize an HTTP client and set default headers:
using (var timeoutController = new CancellationTokenSource(overallTimeout))
using (HttpClient http = AvailabilityTest.NewHttpClient())
{
CancellationToken timeoutControl = timeoutController.Token;
// Run the request and get the response:
using (HttpResponseMessage response = await ExecuteRequestAsync(http, monitoredApiUrl, httpMethod, headers, payload, log, timeoutControl))
{
isAvailabilityTestSuccessful = await ValidateResponseAsync(response, log, timeoutControl);
}
}
return isAvailabilityTestSuccessful;
}
private static async Task<HttpResponseMessage> ExecuteRequestAsync(
HttpClient http,
string monitoredApiUrl,
HttpMethod httpMethod,
IList<KeyValuePair<string, string>> headers,
string payload,
ILogger log,
CancellationToken timeoutControl)
{
log.LogInformation("Preparing request to the monitored URL:"
+ " {{ MonitoredUrl = {MonitoredUrl},"
+ " HttpMethod = {HttpMethod},"
+ " CustomHeaderCount = {CustomRequestHeaderCount},"
+ " PayloadLength = {PayloadLength} }}",
monitoredApiUrl,
httpMethod.ToString(),
headers?.Count ?? 0,
payload?.Length ?? 0);
using (HttpRequestMessage request = new HttpRequestMessage(httpMethod, monitoredApiUrl))
{
if (headers != null)
{
foreach(KeyValuePair<string, string> header in headers)
{
if (! String.IsNullOrWhiteSpace(header.Key))
{
request.Headers.Add(header.Key, header.Value ?? String.Empty);
}
}
}
if (payload != null)
{
request.Content = new StringContent(payload, Encoding.UTF8);
}
log.LogInformation("Initiating request.");
Task<HttpResponseMessage> requestTask = http.SendAsync(request, timeoutControl);
log.LogInformation("Request initiated. Awaiting response.");
HttpResponseMessage response = await requestTask;
if (response == null)
{
log.LogInformation("Response received, but it was NULL.");
return null;
}
KeyValuePair<string, IEnumerable<string>>[] responseHeaders = response.Headers?.ToArray();
log.LogInformation("Response received:"
+ " {{ StatusCodeString = \"{StatusCodeString}\","
+ " StatusCodeNumber = {StatusCodeNumber},"
+ " ReasonPhrase = \"{ReasonPhrase}\","
+ " ResponseHeaderCount = {ResponseHeaderCount}}}",
response.StatusCode.ToString(),
(int) (response.StatusCode),
response.ReasonPhrase,
responseHeaders?.Length ?? 0);
if (responseHeaders != null)
{
foreach(KeyValuePair<string, IEnumerable<string>> header in responseHeaders)
{
string name = header.Key ?? "null";
var value = new StringBuilder();
if (header.Value != null)
{
foreach(string v in header.Value)
{
if (value.Length > 0)
{
value.Append(", ");
}
if (v == null)
{
value.Append("null");
}
else
{
value.Append('"');
value.Append(v);
value.Append('"');
}
}
}
log.LogInformation("Response header parsed: {{ Name = \'{Name}\', Value = \'{Value}\' }}", name, value.ToString());
}
}
return response;
}
}
private static async Task<bool> ValidateResponseAsync(
HttpResponseMessage response,
ILogger log,
CancellationToken timeoutControl)
{
// Add code here to validate the response:
response.EnsureSuccessStatusCode();
string responseContent = await response.Content.ReadAsStringAsync();
bool hasExpectedContent = responseContent.Contains("localTime", StringComparison.OrdinalIgnoreCase)
&& responseContent.Contains("publicTime", StringComparison.OrdinalIgnoreCase)
&& responseContent.Contains("functionTime", StringComparison.OrdinalIgnoreCase)
&& (responseContent.Contains("\"version\": \"4\"", StringComparison.OrdinalIgnoreCase)
|| responseContent.Contains("\"version\":\"4\"", StringComparison.OrdinalIgnoreCase));
return hasExpectedContent;
}
}
}

Просмотреть файл

@ -0,0 +1,14 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"logLevel": {
"default": "Trace"
}
}
}

Просмотреть файл

@ -311,7 +311,7 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost
}
}
}
#pragma warning restore CS0618 // Type or member is obsolete
public static class RuleExtensions
{
@ -334,4 +334,5 @@ namespace Microsoft.Azure.WebJobs.Script.WebHost
bindToCollectorMethod.Invoke(rule, new object[] { patternMatcherInstance });
}
}
#pragma warning restore CS0618 // Type or member is obsolete
}