You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To configure the automated testing on a DSC Config, users need to set up an Azure SP and configure the settings produced in the AppVeyor.yml.
This process usually requires a few steps to perform. It might be a good idea to include some helper functions to assist with doing things like this.
A function like this:
<#.SYNOPSIS New-AzureServicePrincipal.DESCRIPTION This task creates an Azure Service Principal in Azure AD that will be used for all installation automation. This can only be run interactively as the Login-AzureRmAccount will pop up an interactive window for the user to log in with. The output of this task can be used to deploy the application in future and should be stored in each contributors AppVeyor account.#>
[CmdletBinding()]
param
(
[Parameter()]
[System.String]
$Name='DSCConfigurationTest',
[Parameter(Mandatory=$true)]
[System.String]
$SubscriptionId,
[Parameter(Mandatory=$true)]
[System.String]
$ADDomain,
[Parameter(Mandatory=$true)]
[SecureString]
$ApplicationPassword
)
if ($SubscriptionId) {
$account= Login-AzureRmAccount -SubscriptionId $SubscriptionId
} else {
$account= Login-AzureRmAccount
}
Write-Host-Object "Creating '$Name' Service Principal in Azure AD"$app=New-AzureRmADApplication`-DisplayName $Name`-HomePage "https://$ADDomain/$Name"`-IdentifierUris "https://$ADDomain/$Name"`-Password $ApplicationPasswordWrite-Host-Object "Creating Azure AD Service Principal for ApplicationId '$($app.ApplicationId)'"$null=New-AzureRmADServicePrincipal`-ApplicationId $app.ApplicationIdWrite-Host-Object "Assigning role Contributor to AD Service Principal for ApplicationId '$($app.ApplicationId)'"$roleAssignment=$null$retryCount=0while (-not$roleAssignment-and ($retryCount-lt10)) {
try {
$roleAssignment=New-AzureRmRoleAssignment`-RoleDefinitionName Contributor `-ServicePrincipalName $app.ApplicationId`-ErrorAction SilentlyContinue
} catch {
Write-Host-Object "Error assigning role Contributor to AD Service Principal for ApplicationId '$($app.ApplicationId)'. Retrying in 5 seconds..."Start-Sleep-Seconds 5$retryCount++
}
} # whileif (-not$roleAssignment) {
Write-Error-Message "Failed assigning role Contributor to AD Service Principal for ApplicationId '$($app.ApplicationId)'."return
}
Write-Host-Object "'$Name' service principal has been created."Write-Host-Object "ApplicationID is '$($app.ApplicationId)'."Write-Host-Object "SubscriptionID is '$SubscriptionId'."Write-Host-Object "TenantID of '$($account.Context.Tenant.TenantId)'."return [PSObject] @{
ApplicationID=$app.ApplicationIdSubscriptionID=$SubscriptionIdTenantID=$account.Context.Tenant.TenantId
}
To configure the automated testing on a DSC Config, users need to set up an Azure SP and configure the settings produced in the AppVeyor.yml.
This process usually requires a few steps to perform. It might be a good idea to include some helper functions to assist with doing things like this.
A function like this:
This could possibly be added to TestHelper.psm1 in DscConfiguration.Tests