InstrumentationKey parameter using a default IngestionEndpoint

This commit is contained in:
Michael Maxwell 2021-08-20 11:17:58 -07:00
Родитель 322877d296
Коммит c728d89742
1 изменённых файлов: 12 добавлений и 1 удалений

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

@ -1,5 +1,6 @@
param (
[Parameter(Mandatory=$true)][string]$ConnectionString
[string]$ConnectionString,
[string]$InstrumentationKey
)
function ParseConnectionString {
@ -17,6 +18,16 @@ function ParseConnectionString {
return $Map
}
# Exit with error if either both or neither of these parameters are provided
if (("" -eq $ConnectionString) -eq ("" -eq $InstrumentationKey)) {
Write-Error "Please provide one of the parameters: 'ConnectionString' or 'InstrumentationKey'" -ErrorAction Stop
}
# Build the connection string using the instrumentation key
If ($InstrumentationKey) {
$ConnectionString = "InstrumentationKey=$InstrumentationKey;IngestionEndpoint=https://dc.services.visualstudio.com/"
}
$Map = ParseConnectionString($ConnectionString)
$Url = $Map["IngestionEndpoint"] + "v2/track"
$IKey = $Map["InstrumentationKey"]