-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Get-ProductApplicationInsights script
- Loading branch information
1 parent
c84bc57
commit d16e51c
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<# | ||
.SYNOPSIS | ||
Gets and outputs the connection string and resource id of the services application insights. | ||
.DESCRIPTION | ||
Gets and outputs the connection string and resource id of the services application insights. | ||
.PARAMETER AppInsightsResourceGroup | ||
The name of the resource group the application insights is deployed to | ||
.PARAMETER AppInsightsName | ||
The name of the product application insights | ||
.EXAMPLE | ||
.\Get-ProductApplicationInsights.ps1 -ResourceGroupName das-foo-bar-rg -Name das-foo-shared-bar-ai | ||
#> | ||
|
||
[CmdletBinding()] | ||
Param ( | ||
[Parameter(Mandatory = $true)] | ||
[String]$AppInsightsResourceGroup, | ||
[Parameter(Mandatory = $true)] | ||
[String]$AppInsightsName | ||
) | ||
|
||
$applicationInsights = Get-AzApplicationInsights -ResourceGroupName $AppInsightsResourceGroup -Name $AppInsightsName | ||
|
||
$applicationInsightsResourceId = $applicationInsights.Id | ||
$applicationInsightsConnectionString = $applicationInsights.Connectionstring | ||
|
||
Write-Output "Setting value of application insights respirce Id to pipeline variable" | ||
Write-Output "##vso[task.setvariable variable=applicationInsightsResourceId]$applicationInsightsResourceId" | ||
|
||
Write-Output "Setting value of application insights connection string to secret pipeline variable" | ||
Write-Output "##vso[task.setvariable variable=applicationInsightsConnectionString;issecret=true]$applicationInsightsConnectionString" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
$Config = Get-Content $PSScriptRoot\..\Tests\Configuration\Unit.Tests.Config.json -Raw | ConvertFrom-Json | ||
Set-Location $PSScriptRoot\..\Infrastructure-Scripts\ | ||
|
||
Describe "Get-ProductApplicationInsights Unit Tests" -Tags @("Unit") { | ||
|
||
Context "Could not find application insights due to bad paramater values" { | ||
|
||
It "The specified application insights was not found, throw an error" { | ||
Mock Get-ProductApplicationInsights -MockWith { return $null } | ||
{ ./Get-ProductApplicationInsights -AppInsightsResourceGroup $Config.resourceGroupName -AppInsightsName $Config.instanceName } | Should throw | ||
Assert-MockCalled -CommandName 'Get-ProductApplicationInsights' -Times 1 -Scope It | ||
} | ||
|
||
} | ||
|
||
Context "Application insights found" { | ||
|
||
It "Application insights found" { | ||
Mock Get-ProductApplicationInsights -MockWith { return @{ "ApplicationInsightsName" = "ApplicationInsightsName" } } | ||
{ ./Get-ProductApplicationInsights -AppInsightsResourceGroup $Config.resourceGroupName -AppInsightsName $Config.instanceName } | Should not throw | ||
Assert-MockCalled -CommandName 'Get-ProductApplicationInsights' -Times 1 -Scope It | ||
} | ||
|
||
} | ||
|
||
} |