From e743fcbc56477ac24ac5a1e543a0f477dc26f245 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 07:03:42 +0100 Subject: [PATCH 01/10] chore: streamline logging across modules --- .../Scripts/Inject-ArmContent.ps1 | 14 +++--- .../Scripts/Add-AzADAppRoleAssignment.ps1 | 6 +-- .../Scripts/List-AzADAppRoleAssignments.ps1 | 4 +- .../Scripts/Remove-AzADAppRoleAssignment.ps1 | 10 ++--- .../Scripts/Backup-AzApiManagementService.ps1 | 2 +- .../Create-AzApiManagementApiOperation.ps1 | 2 +- .../Create-AzApiManagementUserAccount.ps1 | 2 +- .../Remove-AzApiManagementDefaults.ps1 | 4 +- .../Remove-AzApiManagementUserAccount.ps1 | 2 +- .../Scripts/Set-AzAppServiceSetting.ps1 | 4 +- .../Scripts/Set-AzDataFactoryTriggerState.ps1 | 12 ++--- .../Scripts/Save-AzDevOpsBuild.ps1 | 6 +-- .../Scripts/Set-AzDevOpsArmOutputs.ps1 | 35 ++++++--------- .../Set-AzIntegrationAccountAgreements.ps1 | 17 ++++--- .../Set-AzIntegrationAccountAssemblies.ps1 | 15 +++---- .../Set-AzIntegrationAccountCertificates.ps1 | 17 ++++--- .../Scripts/Set-AzIntegrationAccountMaps.ps1 | 17 ++++--- .../Set-AzIntegrationAccountPartners.ps1 | 17 ++++--- .../Set-AzIntegrationAccountSchemas.ps1 | 18 +++----- .../Scripts/Get-AzKeyVaultAccessPolicies.ps1 | 6 +-- .../Scripts/Set-AzKeyVaultSecretFromFile.ps1 | 2 +- .../Scripts/Disable-AzLogicApp.ps1 | 12 ++--- .../Scripts/Disable-AzLogicAppsFromConfig.ps1 | 45 +++++++++---------- .../Scripts/Enable-AzLogicApp.ps1 | 10 ++--- .../Scripts/Enable-AzLogicAppsFromConfig.ps1 | 23 +++++----- .../Get-AzLogicAppResourceManagementUrl.ps1 | 21 +++++---- 26 files changed, 149 insertions(+), 174 deletions(-) diff --git a/src/Arcus.Scripting.ARM/Scripts/Inject-ArmContent.ps1 b/src/Arcus.Scripting.ARM/Scripts/Inject-ArmContent.ps1 index 8dd2769c..fe908652 100644 --- a/src/Arcus.Scripting.ARM/Scripts/Inject-ArmContent.ps1 +++ b/src/Arcus.Scripting.ARM/Scripts/Inject-ArmContent.ps1 @@ -33,7 +33,7 @@ function InjectFile { [string] $filePath ) - Write-Host "Checking file $filePath" + Write-Verbose "Checking ARM template file '$filePath' for injection tokens..." $replaceContentDelegate = { param($match) @@ -58,7 +58,7 @@ function InjectFile { # Inject content recursively first InjectFile($fullPathOfFileToInject) - Write-Host "`t Injecting content of $fullPathOfFileToInject into $filePath" + Write-Verbose "`t Injecting content of '$fullPathOfFileToInject' into '$filePath'" $newString = Get-Content -Path $fullPathOfFileToInject -Raw @@ -98,13 +98,13 @@ function InjectFile { if ($optionParts.Contains("InjectAsJsonObject")) { try { # Test if content is valid JSON - Write-Host "Test if valid JSON: $newString" + Write-Verbose "Test if valid JSON: $newString" ConvertFrom-Json $newString $surroundContentWithDoubleQuotes = $False } catch { - Write-Warning "Content to inject cannot be parsed as a JSON object!" + Write-Warning "Content to inject into ARM template file '$filePath' cannot be parsed as a JSON object!" } } } @@ -122,7 +122,7 @@ function InjectFile { $injectionInstructionRegex = [regex] '"?\${(.+)}\$"?'; $injectionInstructionRegex.Replace($rawContents, $replaceContentDelegate) | Set-Content $filePath -NoNewline -Encoding UTF8 - Write-Host "Done checking file $filePath" + Write-Host "Done checking ARM template file '$filePath' for injection tokens" -ForegroundColor Green } @@ -133,9 +133,9 @@ if ($false -eq $PathIsFound) { throw "Passed along path '$Path' doesn't point to valid file path" } -Write-Host "Starting $psScriptFileName script on path $Path" +Write-Verbose "Starting '$psScriptFileName' script on path '$Path'..." $armTemplates = Get-ChildItem -Path $Path -Recurse -Include *.json $armTemplates | ForEach-Object { InjectFile($_.FullName) } -Write-Host "Finished script $psScriptFileName" \ No newline at end of file +Write-Host "Finished script '$psScriptFileName' on path '$Path'" -ForegroundColor Green \ No newline at end of file diff --git a/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 b/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 index 5a63a169..f28ed3d7 100644 --- a/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 +++ b/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 @@ -38,11 +38,11 @@ try { $adApplication.AppRole += $newRole Update-AzADApplication -ObjectId $adApplication.Id -AppRole $adApplication.AppRole - Write-Host "Added role '$Role' to Active Directory Application '$($adApplication.DisplayName)'" -ForegroundColor White + Write-Host "Added role '$Role' to Active Directory Application '$($adApplication.DisplayName)e'" $currentAppRole = $newRole } else { - Write-Host "Active Directory Application '$($adApplication.DisplayName)' already contains the role '$Role'" -ForegroundColor Yellow + Write-Warning "Active Directory Application '$($adApplication.DisplayName)' already contains the role '$Role'" $currentAppRole = $adApplication.AppRole | Where-Object Value -eq $Role } @@ -64,7 +64,7 @@ try { $newRoleAssignment = New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $adServicePrincipalRoleAssignTo.Id -PrincipalId $adServicePrincipalRoleAssignTo.Id -ResourceId $adServicePrincipal.Id -AppRoleId $currentAppRole.Id Write-Host "Role Assignment for the role '$Role' added to the Active Directory Application '$($adApplicationRoleAssignTo.DisplayName)'" -ForegroundColor Green } else { - Write-Host "Active Directory Application '$($adApplicationRoleAssignTo.DisplayName)' already contains a role assignment for the role '$Role'" -ForegroundColor Yellow + Write-Warning "Active Directory Application '$($adApplicationRoleAssignTo.DisplayName)' already contains a role assignment for the role '$Role'" } } catch { throw "Adding the role '$Role' for the Active Directory Application with ClientId '$ClientId' failed. Details: $($_.Exception.Message)" diff --git a/src/Arcus.Scripting.ActiveDirectory/Scripts/List-AzADAppRoleAssignments.ps1 b/src/Arcus.Scripting.ActiveDirectory/Scripts/List-AzADAppRoleAssignments.ps1 index 85850a1a..ed2488fb 100644 --- a/src/Arcus.Scripting.ActiveDirectory/Scripts/List-AzADAppRoleAssignments.ps1 +++ b/src/Arcus.Scripting.ActiveDirectory/Scripts/List-AzADAppRoleAssignments.ps1 @@ -26,7 +26,7 @@ if ($RolesAssignedToClientId -ne '') { try { if ($adApplication.AppRole.Count -eq 0) { - Write-Host "No roles found in Active Directory Application '$($adApplication.DisplayName)'" -ForegroundColor Yellow + Write-Warning "No roles found in Active Directory Application '$($adApplication.DisplayName)'" } foreach ($appRole in $adApplication.AppRole) { @@ -45,7 +45,7 @@ try { } } } else { - Write-Host "No role assignments found in Active Directory Application '$($adApplication.DisplayName)'" -ForegroundColor Yellow + Write-Warning "No role assignments found in Active Directory Application '$($adApplication.DisplayName)'" } } } catch { diff --git a/src/Arcus.Scripting.ActiveDirectory/Scripts/Remove-AzADAppRoleAssignment.ps1 b/src/Arcus.Scripting.ActiveDirectory/Scripts/Remove-AzADAppRoleAssignment.ps1 index ae71efc4..d4ed8516 100644 --- a/src/Arcus.Scripting.ActiveDirectory/Scripts/Remove-AzADAppRoleAssignment.ps1 +++ b/src/Arcus.Scripting.ActiveDirectory/Scripts/Remove-AzADAppRoleAssignment.ps1 @@ -25,16 +25,16 @@ if (!$adServicePrincipalRoleRemoveFrom) { try { if ($adApplication.AppRole.Value -notcontains $Role) { - Write-Host "Active Directory Application '$($adApplication.DisplayName)' does not contain the role '$Role', skipping removal" -ForegroundColor Yellow + Write-Warning "Active Directory Application '$($adApplication.DisplayName)' does not contain the role '$Role', skipping removal" } else { $appRole = $adApplication.AppRole | Where-Object {($_.DisplayName -eq $Role)} $appRoleAssignment = Get-MgServicePrincipalAppRoleAssignedTo -ServicePrincipalId $adServicePrincipal.Id | Where-Object {($_.AppRoleId -eq $appRole.Id) -and ($_.PrincipalId -eq $adServicePrincipalRoleRemoveFrom.Id)} if ($appRoleAssignment) { Remove-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $adServicePrincipalRoleRemoveFrom.Id -AppRoleAssignmentId $appRoleAssignment.Id - Write-Host "Role assignment for '$Role' has been removed from Active Directory Application '$($adApplicationRoleRemoveFrom.DisplayName)'" + Write-Host "Role assignment for '$Role' has been removed from Active Directory Application '$($adApplicationRoleRemoveFrom.DisplayName)'" -ForegroundColor Green } else { - Write-Host "Role '$Role' is not assigned to Active Directory Application '$($adApplicationRoleRemoveFrom.DisplayName)', skipping role assignment removal" -ForegroundColor Yellow + Write-Warning "Role '$Role' is not assigned to Active Directory Application '$($adApplicationRoleRemoveFrom.DisplayName)', skipping role assignment removal" } if ($RemoveRoleIfNoAssignmentsAreLeft) { @@ -49,10 +49,10 @@ try { $appRoles = $adApplication.AppRole | Where-Object Id -ne $appRole.Id if ($appRoles) { Update-AzADApplication -ObjectId $adApplication.Id -AppRole $appRoles - Write-Host "Role '$Role' with App Role '$appRoles' removed from Active Directory Application '$($adApplication.DisplayName)' as no more role assignments were left and the option 'RemoveRoleIfNoAssignmentsAreLeft' is set" + Write-Host "Role '$Role' with App Role '$appRoles' removed from Active Directory Application '$($adApplication.DisplayName)' as no more role assignments were left and the option 'RemoveRoleIfNoAssignmentsAreLeft' is set" -ForegroundColor Green } else { Update-AzADApplication -ObjectId $adApplication.Id -AppRole @() - Write-Host "Role '$Role' removed from Active Directory Application '$($adApplication.DisplayName)' as no more role assignments were left and the option 'RemoveRoleIfNoAssignmentsAreLeft' is set" + Write-Host "Role '$Role' removed from Active Directory Application '$($adApplication.DisplayName)' as no more role assignments were left and the option 'RemoveRoleIfNoAssignmentsAreLeft' is set" -ForegroundColor Green } } } diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Backup-AzApiManagementService.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Backup-AzApiManagementService.ps1 index 2af43097..ef62c6b9 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Backup-AzApiManagementService.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Backup-AzApiManagementService.ps1 @@ -18,7 +18,7 @@ if ($storageKeys -eq $null -or $storageKeys.count -eq 0) { Write-Host "Got Azure storage key for storage account '$($StorageAccountName)' in resource group '$($StorageAccountResourceGroupName)'!" -ForegroundColor Green $storageKey = $storageKeys[0] - Write-Verbose "Create new Azure storage context for storage account '$($StorageAccountName)' with storage key..." + Write-Verbose "Creating new Azure storage context for storage account '$($StorageAccountName)' with storage key..." $storageContext = New-AzStorageContext -StorageAccountName $StorageAccountName -StorageAccountKey $storageKey.Value Write-Host "New Azure storage context for storage account '$($StorageAccountName)' with storage key created!" -ForegroundColor Green diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 index 3cc4a8e9..3a1478ec 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 @@ -21,7 +21,7 @@ Write-Host "New API operation '$OperationName' was added on Azure API Management if($OperationId -eq "" -or $PolicyFilePath -eq "") { - Write-Host "No policy has been defined for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" -ForegroundColor Yellow + Write-Warning "No policy has been defined for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" } else { diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementUserAccount.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementUserAccount.ps1 index e1f74122..bd90a0da 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementUserAccount.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementUserAccount.ps1 @@ -73,7 +73,7 @@ try { Write-Host "Account has been created for $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" -ForegroundColor Green if($Password -eq $null -or $Password -eq ""){ - Write-Host "Since no password was provided, one has been generated. Please advise the user to change this password the first time logging in for the Azure API Management service '$($ServiceName)' in resource group '$($ResourceGroupName)'" -ForegroundColor Yellow + Write-Warning "Since no password was provided, one has been generated. Please advise the user to change this password the first time logging in for the Azure API Management service '$($ServiceName)' in resource group '$($ResourceGroupName)'" } } diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementDefaults.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementDefaults.ps1 index 90d2a4f2..393e4603 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementDefaults.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementDefaults.ps1 @@ -12,7 +12,7 @@ $apimContext = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName $exceptionOccurred = $false $failedActions = @() -Write-Host "Checking if 'echo' API exists in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'..." +Write-Verbose "Checking if 'echo' API exists in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'..." $echoExists = $true try { Get-AzApiManagementApi -Context $apimContext -ApiId 'echo-api' -ErrorAction Stop | Out-Null @@ -70,7 +70,7 @@ if ($starterExists) { } } -Write-Host "Checking if 'unlimited' product exists..." +Write-Verbose "Checking if 'unlimited' product exists in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'..." $unlimitedExists = $true try { Get-AzApiManagementProduct -Context $apimContext -ProductId 'unlimited' -ErrorAction Stop | Out-Null diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementUserAccount.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementUserAccount.ps1 index f8a6b9b5..b6015039 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementUserAccount.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Remove-AzApiManagementUserAccount.ps1 @@ -31,7 +31,7 @@ try { Remove-AzApiManagementUser -Context $apimContext -UserId $apimUserId Write-Host "Removed the user account with e-mail '$MailAddress' and ID '$apimUserId' for the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" -ForegroundColor Green } else { - Write-Host "User account with e-mail '$MailAddress' not found in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" + Write-Warning "User account with e-mail '$MailAddress' not found in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" } } catch { diff --git a/src/Arcus.Scripting.AppService/Scripts/Set-AzAppServiceSetting.ps1 b/src/Arcus.Scripting.AppService/Scripts/Set-AzAppServiceSetting.ps1 index 075ad3f6..7e1791ee 100644 --- a/src/Arcus.Scripting.AppService/Scripts/Set-AzAppServiceSetting.ps1 +++ b/src/Arcus.Scripting.AppService/Scripts/Set-AzAppServiceSetting.ps1 @@ -13,7 +13,7 @@ if ($appService -eq $null) { throw "No Azure App Service with name '$AppServiceName' could be found in the resource group '$ResourceGroupName'" } -Write-Host "Azure App service has been found for name '$AppServiceName' in the resource group '$ResourceGroupName'" -ForegroundColor Green +Write-Host "Azure App service has been found for name '$AppServiceName' in the resource group '$ResourceGroupName'" Write-Verbose "Extracting the existing application settings from the Azure App Service '$AppServiceName' in the resource group '$ResourceGroupName'..." $appServiceSettings = $appService.SiteConfig.AppSettings @@ -47,4 +47,4 @@ try throw "The Azure App Service settings could not be updated for the Azure App Service '$AppServiceName' in the resource group '$ResourceGroupName'. Details: $($_.Exception.Message)" } -Write-Host "Successfully set the application setting '$AppServiceSettingName' of the Azure App Service '$AppServiceName' in resource group '$ResourceGroupName'" \ No newline at end of file +Write-Host "Successfully set the application setting '$AppServiceSettingName' of the Azure App Service '$AppServiceName' in resource group '$ResourceGroupName'" -ForegroundColor Green \ No newline at end of file diff --git a/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 b/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 index 5e90025d..5f65df47 100644 --- a/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 +++ b/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 @@ -28,8 +28,8 @@ catch } else { - Write-Host $message - Write-Host "Skipping the '$Action'-operation." + Write-Warning $message + Write-verbose "Skipping the '$Action'-operation." return } } @@ -41,12 +41,12 @@ if($Action -eq "Start") if($null -ne $DataFactoryTrigger) { $succeeded = Start-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataFactoryTriggerName -Force -ErrorAction Stop - Write-Host "The trigger '$DataFactoryTriggerName' has been started." + Write-Host "Started Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" -ForegroundColor Green } } catch { - throw "Error starting trigger '$DataFactoryTriggerName' in data factory '$DataFactoryName'" + throw "Error starting Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" } } @@ -57,11 +57,11 @@ if($Action -eq "Stop") if($null -ne $DataFactoryTrigger) { $succeeded = Stop-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataFactoryTriggerName -Force -ErrorAction Stop - Write-Host "The trigger '$DataFactoryTriggerName' has been stopped." + Write-Host "Stopped Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" -ForegroundColor Green } } catch { - throw "Error stopping trigger '$DataFactoryTrigger' in data factory '$DataFactoryName'" + throw "Error stopping Azure Data Factory trigger '$DataFactoryTrigger' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" } } \ No newline at end of file diff --git a/src/Arcus.Scripting.DevOps/Scripts/Save-AzDevOpsBuild.ps1 b/src/Arcus.Scripting.DevOps/Scripts/Save-AzDevOpsBuild.ps1 index 2560ce06..e303beec 100644 --- a/src/Arcus.Scripting.DevOps/Scripts/Save-AzDevOpsBuild.ps1 +++ b/src/Arcus.Scripting.DevOps/Scripts/Save-AzDevOpsBuild.ps1 @@ -16,11 +16,11 @@ if ($collectionUri.EndsWith('/') -eq $false) { $requestUri = "$collectionUri" + "$ProjectId/_apis/build/builds/" + $BuildId + "?api-version=6.0" -Write-Verbose "Saving Azure DevOps build with build ID $BuildId in project $ProjectId by posting $requestBody to $requestUri" +Write-Verbose "Saving Azure DevOps build with build ID $BuildId in project $ProjectId by posting '$requestBody' to '$requestUri'..." $response = Invoke-WebRequest -Uri $requestUri -Method Patch -Body $requestBody -ContentType "application/json" -Headers @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } if ($response.StatusCode -ne 200) { - throw "Unable to retain build indefinetely. API request returned statuscode $($response.StatusCode)" + throw "Unable to retain Azure DevOps build indefinetely with build ID $BuildId in project $ProjectId. API request returned statuscode $($response.StatusCode)" } -Write-Host "Azure DevOps build with build ID $BuildId in project $ProjectId saved" \ No newline at end of file +Write-Host "Saved Azure DevOps build with build ID $BuildId in project $ProjectId" -ForegroundColor Green \ No newline at end of file diff --git a/src/Arcus.Scripting.DevOps/Scripts/Set-AzDevOpsArmOutputs.ps1 b/src/Arcus.Scripting.DevOps/Scripts/Set-AzDevOpsArmOutputs.ps1 index 83d1e6e4..f8386a72 100644 --- a/src/Arcus.Scripting.DevOps/Scripts/Set-AzDevOpsArmOutputs.ps1 +++ b/src/Arcus.Scripting.DevOps/Scripts/Set-AzDevOpsArmOutputs.ps1 @@ -16,19 +16,14 @@ function Add-VariableGroupVariable() ) BEGIN { - #Retrieve project details - Write-Host Retrieving project details - + Write-Verbose "Retrieving Azure DevOps project details for variable group '$VariableGroupName'..." [String]$project = "$env:SYSTEM_TEAMPROJECT" [String]$projectUri = "$env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI" [String]$apiVersion = "4.1-preview.1" - - Write-Host Project: $project - Write-Host ProjectUri: $projectUri + Write-Debug "Using Azure DevOps project: $project, project URI: $projectUri" - #Set authorization headers - Write-Host Set authorization headers + Write-Verbose "Setting authorization headers to retrieve potential existing Azure DevOps variable group '$VariableGroupName'..." if ([string]::IsNullOrEmpty($env:SYSTEM_ACCESSTOKEN)) { Write-Error "The SYSTEM_ACCESSTOKEN environment variable is empty. Remember to explicitly allow the build job to access the OAuth Token!" @@ -36,10 +31,10 @@ function Add-VariableGroupVariable() $headers = @{ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" } - #Get variable group - Write-Host Get variable group + Write-Verbose "Getting Azure DevOps variable group '$VariableGroupName'..." $getVariableGroupUrl= $projectUri + $project + "/_apis/distributedtask/variablegroups?api-version=" + $apiVersion + "&groupName=" + $VariableGroupName - $variableGroup = (Invoke-RestMethod -Uri $getVariableGroupUrl -Headers $headers -Verbose) + $variableGroup = (Invoke-RestMethod -Uri $getVariableGroupUrl -Headers $headers -Verbose) + $releaseName = $env:RELEASE_RELEASENAME if ([string]::IsNullOrEmpty($releaseName)) { @@ -48,34 +43,30 @@ function Add-VariableGroupVariable() if($variableGroup.value) { - #Set properties for update of existing variable group - Write-Host Set properties for update of existing variable group + Write-Host "Set properties for update of existing Azure DevOps variable group '$variableGroupName'" $variableGroup = $variableGroup.value[0] - $variableGroup | Add-Member -Name "description" -MemberType NoteProperty -Value "Variable group that got auto-updated by release '$releaseName'." -Force + $variableGroup | Add-Member -Name "description" -MemberType NoteProperty -Value "Variable group that got auto-updated by release '$releaseName'." -Force $method = "Put" $upsertVariableGroupUrl = $projectUri + $project + "/_apis/distributedtask/variablegroups/" + $variableGroup.id + "?api-version=" + $apiVersion } else { - #Set properties for creation of new variable group - Write-Host Set properties for creation of new variable group + Write-Host "Set properties for creation of new Azure DevOps variable group '$VariableGroupName'" $variableGroup = @{name=$VariableGroupName;type="Vsts";description="Variable group that got auto-updated by release '$releaseName'.";variables=New-Object PSObject;} $method = "Post" $upsertVariableGroupUrl = $projectUri + $project + "/_apis/distributedtask/variablegroups?api-version=" + $apiVersion } - #Add variable $variableGroup.variables | Add-Member -Name $variableName -MemberType NoteProperty -Value @{value=$variableValue} -Force - #Upsert variable group - Write-Host Upsert variable group + Write-Verbose "Upserting Azure DevOps variable group '$variableGroupName'..." $body = $variableGroup | ConvertTo-Json -Depth 10 -Compress - Write-Host $body + Write-Debug $body Invoke-RestMethod $upsertVariableGroupUrl -Method $method -Body $body -Headers $headers -ContentType 'application/json; charset=utf-8' -Verbose } } -Write-Host "Get ARM outputs from '$ArmOutputsEnvironmentVariableName' environment variable" +Write-Verbose "Geting ARM outputs from '$ArmOutputsEnvironmentVariableName' environment variable..." $json = [System.Environment]::GetEnvironmentVariable($ArmOutputsEnvironmentVariableName) $armOutputs = ConvertFrom-Json $json @@ -89,7 +80,7 @@ foreach ($output in $armOutputs.PSObject.Properties) { } if ($UpdateVariablesForCurrentJob) { - Write-Host The pipeline variable $variableName will be updated to value $variableValue, so it can be used in subsequent tasks of the current job. + Write-Host "The pipeline variable $variableName will be updated to value $variableValue, so it can be used in subsequent tasks of the current job" Write-Host "##vso[task.setvariable variable=$variableName]$variableValue" } } \ No newline at end of file diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAgreements.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAgreements.ps1 index a9fc0c0f..bd6a414c 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAgreements.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAgreements.ps1 @@ -25,7 +25,7 @@ function UploadAgreement { if ($ArtifactsPrefix -ne '') { $agreementName = $ArtifactsPrefix + $agreementName } - Write-Host "Uploading agreement '$agreementName' into the Integration Account '$Name'" + Write-Verbose "Uploading agreement '$agreementName' into the Azure Integration Account '$Name'..." $agreementType = $agreementData.properties.agreementType if ($agreementType -eq $null -or $agreementType -eq '') { @@ -69,12 +69,12 @@ function UploadAgreement { $existingAgreement = $null try { - Write-Verbose "Checking if the agreement '$agreementName' already exists in the Azure Integration Account '$Name'" + Write-Verbose "Checking if the agreement '$agreementName' already exists in the Azure Integration Account '$Name'..." $existingAgreement = Get-AzIntegrationAccountAgreement -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -AgreementName $agreementName -ErrorAction Stop } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No agreement '$agreementName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No agreement '$agreementName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -83,16 +83,16 @@ function UploadAgreement { try { if ($existingAgreement -eq $null) { - Write-Verbose "Creating agreement '$agreementName' in Azure Integration Account '$Name'" + Write-Verbose "Creating agreement '$agreementName' in Azure Integration Account '$Name'..." $createdAgreement = New-AzIntegrationAccountAgreement -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -AgreementName $agreementName -AgreementType $agreementType -HostPartner $hostPartner -HostIdentityQualifier $hostIdentityQualifier -HostIdentityQualifierValue $hostIdentityQualifierValue -GuestPartner $guestPartner -GuestIdentityQualifier $guestIdentityQualifier -GuestIdentityQualifierValue $guestIdentityQualifierValue -AgreementContent $agreementContent -ErrorAction Stop - Write-Verbose ($createdAgreement | Format-List -Force | Out-String) + Write-Debug ($createdAgreement | Format-List -Force | Out-String) } else { - Write-Verbose "Updating agreement '$agreementName' in Azure Integration Account '$Name'" + Write-Verbose "Updating agreement '$agreementName' in Azure Integration Account '$Name'..." $updatedAgreement = Set-AzIntegrationAccountAgreement -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -AgreementName $agreementName -AgreementType $agreementType -HostPartner $hostPartner -HostIdentityQualifier $hostIdentityQualifier -HostIdentityQualifierValue $hostIdentityQualifierValue -GuestPartner $guestPartner -GuestIdentityQualifier $guestIdentityQualifier -GuestIdentityQualifierValue $guestIdentityQualifierValue -AgreementContent $agreementContent -Force -ErrorAction Stop - Write-Verbose ($updatedAgreement | Format-List -Force | Out-String) + Write-Debug ($updatedAgreement | Format-List -Force | Out-String) } - Write-Host "Agreement '$agreementName' has been uploaded into the Azure Integration Account '$Name'" + Write-Host "Agreement '$agreementName' has been uploaded into the Azure Integration Account '$Name'" -ForegroundColor Green } catch { Write-Error "Failed to upload agreement '$agreementName' in Azure Integration Account '$Name': '$($_.Exception.Message)'" @@ -107,7 +107,6 @@ else { if ($AgreementsFolder -ne '' -and $AgreementFilePath -eq '') { foreach ($agreement in Get-ChildItem($AgreementsFolder) -File) { UploadAgreement -Agreement $agreement - Write-Host '----------' } } elseif ($AgreementsFolder -eq '' -and $AgreementFilePath -ne '') { diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAssemblies.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAssemblies.ps1 index 7110ad2b..0bd2d4fa 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAssemblies.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountAssemblies.ps1 @@ -20,16 +20,16 @@ function UploadAssembly { if ($ArtifactsPrefix -ne '') { $assemblyName = $ArtifactsPrefix + $assemblyName } - Write-Host "Uploading assembly '$assemblyName' into the Azure Integration Account '$Name'" + Write-Verbose "Uploading assembly '$assemblyName' into the Azure Integration Account '$Name'..." $existingAssembly = $null try { - Write-Verbose "Checking if the assembly '$assemblyName' already exists in the Azure Integration Account '$Name'" + Write-Verbose "Checking if the assembly '$assemblyName' already exists in the Azure Integration Account '$Name'..." $existingAssembly = Get-AzIntegrationAccountAssembly -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -Name $assemblyName -ErrorAction Stop } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No assembly '$assemblyName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No assembly '$assemblyName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -38,14 +38,14 @@ function UploadAssembly { try { if ($existingAssembly -eq $null) { - Write-Verbose "Creating assembly '$assemblyName' in Azure Integration Account '$Name'" + Write-Verbose "Creating assembly '$assemblyName' in Azure Integration Account '$Name'..." $createdAssembly = New-AzIntegrationAccountAssembly -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -Name $assemblyName -AssemblyFilePath $Assembly.FullName -ErrorAction Stop - Write-Verbose ($createdAssembly | Format-List -Force | Out-String) + Write-Debug ($createdAssembly | Format-List -Force | Out-String) } else { - Write-Verbose "Updating assembly '$assemblyName' in Azure Integration Account '$Name'" + Write-Verbose "Updating assembly '$assemblyName' in Azure Integration Account '$Name'..." $updatedAssembly = Set-AzIntegrationAccountAssembly -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -Name $assemblyName -AssemblyFilePath $Assembly.FullName -ErrorAction Stop - Write-Verbose ($updatedAssembly | Format-List -Force | Out-String) + Write-Debug ($updatedAssembly | Format-List -Force | Out-String) } Write-Host "Assembly '$assemblyName' has been uploaded into the Azure Integration Account '$Name'" } @@ -62,7 +62,6 @@ else { if ($AssembliesFolder -ne '' -and $AssemblyFilePath -eq '') { foreach ($assembly in Get-ChildItem($AssembliesFolder) -File) { UploadAssembly -Assembly $assembly - Write-Host '----------' } } elseif ($AssembliesFolder -eq '' -and $AssemblyFilePath -ne '') { diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountCertificates.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountCertificates.ps1 index 3aaf38d7..362009d2 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountCertificates.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountCertificates.ps1 @@ -32,16 +32,16 @@ function UploadCertificate { if ($ArtifactsPrefix -ne '') { $certificateName = $ArtifactsPrefix + $certificateName } - Write-Host "Uploading certificate '$certificateName' into the Azure Integration Account '$Name'" + Write-Host "Uploading certificate '$certificateName' into the Azure Integration Account '$Name'..." $existingCertificate = $null try { - Write-Verbose "Checking if the certificate '$certificateName' already exists in the Azure Integration Account '$Name'" + Write-Verbose "Checking if the certificate '$certificateName' already exists in the Azure Integration Account '$Name'..." $existingCertificate = Get-AzIntegrationAccountCertificate -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -CertificateName $certificateName -ErrorAction Stop } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No certificate '$certificateName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No certificate '$certificateName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -50,26 +50,26 @@ function UploadCertificate { try { if ($existingCertificate -eq $null) { - Write-Verbose "Creating certificate '$certificateName' in Azure Integration Account '$Name'" + Write-Verbose "Creating certificate '$certificateName' in Azure Integration Account '$Name'..." if ($CertificateType -eq 'Public') { $createdCertificate = New-AzIntegrationAccountCertificate -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -CertificateName $certificateName -PublicCertificateFilePath $Certificate.FullName -ErrorAction Stop } else { $createdCertificate = New-AzIntegrationAccountCertificate -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -CertificateName $certificateName -PublicCertificateFilePath $Certificate.FullName -KeyName $KeyName -KeyVersion $KeyVersion -KeyVaultId $KeyVaultId -ErrorAction Stop } - Write-Verbose ($createdCertificate | Format-List -Force | Out-String) + Write-Debug ($createdCertificate | Format-List -Force | Out-String) } else { - Write-Verbose "Updating certificate '$certificateName' in Azure Integration Account '$Name'" + Write-Verbose "Updating certificate '$certificateName' in Azure Integration Account '$Name'..." if ($CertificateType -eq 'Public') { $updatedCertificate = Set-AzIntegrationAccountCertificate -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -CertificateName $certificateName -PublicCertificateFilePath $Certificate.FullName -Force -ErrorAction Stop } else { $updatedCertificate = Set-AzIntegrationAccountCertificate -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -CertificateName $certificateName -PublicCertificateFilePath $Certificate.FullName -KeyName $KeyName -KeyVersion $KeyVersion -KeyVaultId $KeyVaultId -Force -ErrorAction Stop } - Write-Verbose ($updatedCertificate | Format-List -Force | Out-String) + Write-Debug ($updatedCertificate | Format-List -Force | Out-String) } - Write-Host "Certificate '$certificateName' has been uploaded into the Azure Integration Account '$Name'" + Write-Host "Certificate '$certificateName' has been uploaded into the Azure Integration Account '$Name'" -ForegroundColor Green } catch { Write-Error "Failed to upload certificate '$certificateName' in Azure Integration Account '$Name': '$($_.Exception.Message)'" @@ -84,7 +84,6 @@ else { if ($CertificatesFolder -ne '' -and $CertificateFilePath -eq '') { foreach ($certificate in Get-ChildItem($CertificatesFolder) -File) { UploadCertificate -Certificate $certificate - Write-Host '----------' } } elseif ($CertificatesFolder -eq '' -and $CertificateFilePath -ne '') { diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountMaps.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountMaps.ps1 index 87636187..68cc33dd 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountMaps.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountMaps.ps1 @@ -25,16 +25,16 @@ function UploadMap { if ($ArtifactsPrefix -ne '') { $mapName = $ArtifactsPrefix + $mapName } - Write-Host "Uploading map '$mapName' into the Azure Integration Account '$Name'" + Write-Verbose "Uploading map '$mapName' into the Azure Integration Account '$Name'..." $existingMap = $null try { - Write-Verbose "Checking if the map '$mapName' already exists in the Azure Integration Account '$Name'" + Write-Verbose "Checking if the map '$mapName' already exists in the Azure Integration Account '$Name'..." $existingMap = Get-AzIntegrationAccountMap -ResourceGroupName $ResourceGroupName -Name $Name -MapName $mapName -ErrorAction Stop } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No map '$mapName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No map '$mapName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -43,16 +43,16 @@ function UploadMap { try { if ($existingMap -eq $null) { - Write-Verbose "Creating map '$mapName' in Azure Integration Account '$Name'" + Write-Verbose "Creating map '$mapName' in Azure Integration Account '$Name'..." $createdMap = New-AzIntegrationAccountMap -ResourceGroupName $ResourceGroupName -Name $Name -MapName $mapName -MapType $MapType -MapFilePath $Map.FullName -ErrorAction Stop - Write-Verbose ($createdMap | Format-List -Force | Out-String) + Write-Debug ($createdMap | Format-List -Force | Out-String) } else { - Write-Verbose "Updating map '$mapName' in Azure Integration Account '$Name'" + Write-Verbose "Updating map '$mapName' in Azure Integration Account '$Name'..." $updatedMap = Set-AzIntegrationAccountMap -ResourceGroupName $ResourceGroupName -Name $Name -MapName $mapName -MapFilePath $Map.FullName -ErrorAction Stop -Force - Write-Verbose ($updatedMap | Format-List -Force | Out-String) + Write-Debug ($updatedMap | Format-List -Force | Out-String) } - Write-Host "Map '$mapName' has been uploaded into the Azure Integration Account '$Name'" + Write-Host "Map '$mapName' has been uploaded into the Azure Integration Account '$Name'" -ForegroundColor Green } catch { Write-Error "Failed to upload map '$mapName' in Azure Integration Account '$Name': '$($_.Exception.Message)'" @@ -67,7 +67,6 @@ else { if ($MapsFolder -ne '' -and $MapFilePath -eq '') { foreach ($map in Get-ChildItem($MapsFolder) -File) { UploadMap -Map $map - Write-Host '----------' } } elseif ($MapsFolder -eq '' -and $MapFilePath -ne '') { diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountPartners.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountPartners.ps1 index 4a62c026..126cd095 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountPartners.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountPartners.ps1 @@ -25,7 +25,7 @@ function UploadPartner { if ($ArtifactsPrefix -ne '') { $partnerName = $ArtifactsPrefix + $partnerName } - Write-Host "Uploading partner '$partnerName' into the Azure Integration Account '$Name'" + Write-Verbose "Uploading partner '$partnerName' into the Azure Integration Account '$Name'..." $businessIdentities = $null foreach ($businessIdentity in $partnerData.properties.content.b2b.businessIdentities) { @@ -41,12 +41,12 @@ function UploadPartner { $existingPartner = $null try { - Write-Verbose "Checking if the partner '$partnerName' already exists in the Azure Integration Account '$Name'" + Write-Verbose "Checking if the partner '$partnerName' already exists in the Azure Integration Account '$Name'..." $existingPartner = Get-AzIntegrationAccountPartner -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -PartnerName $partnerName -ErrorAction Stop } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No partner '$partnerName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No partner '$partnerName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -55,16 +55,16 @@ function UploadPartner { try { if ($existingPartner -eq $null) { - Write-Verbose "Creating partner '$partnerName' in Azure Integration Account '$Name'" + Write-Verbose "Creating partner '$partnerName' in Azure Integration Account '$Name'..." $createdPartner = New-AzIntegrationAccountPartner -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -PartnerName $partnerName -BusinessIdentities $businessIdentities -ErrorAction Stop - Write-Verbose ($createdPartner | Format-List -Force | Out-String) + Write-Debug ($createdPartner | Format-List -Force | Out-String) } else { - Write-Verbose "Updating partner '$partnerName' in Azure Integration Account '$Name'" + Write-Verbose "Updating partner '$partnerName' in Azure Integration Account '$Name'..." $updatedPartner = Set-AzIntegrationAccountPartner -ResourceGroupName $ResourceGroupName -IntegrationAccount $Name -PartnerName $partnerName -BusinessIdentities $businessIdentities -Force -ErrorAction Stop - Write-Verbose ($updatedPartner | Format-List -Force | Out-String) + Write-Debug ($updatedPartner | Format-List -Force | Out-String) } - Write-Host "Partner '$partnerName' has been uploaded into the Azure Integration Account '$Name'" + Write-Host "Partner '$partnerName' has been uploaded into the Azure Integration Account '$Name'" -ForegroundColor Green } catch { Write-Error "Failed to upload partner '$partnerName' in Azure Integration Account '$Name': '$($_.Exception.Message)'" @@ -79,7 +79,6 @@ else { if ($PartnersFolder -ne '' -and $PartnerFilePath -eq '') { foreach ($partner in Get-ChildItem($PartnersFolder) -File) { UploadPartner -Partner $partner - Write-Host '----------' } } elseif ($PartnersFolder -eq '' -and $PartnerFilePath -ne '') { diff --git a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountSchemas.ps1 b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountSchemas.ps1 index 582f01c2..742b718c 100644 --- a/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountSchemas.ps1 +++ b/src/Arcus.Scripting.IntegrationAccount/Scripts/Set-AzIntegrationAccountSchemas.ps1 @@ -24,9 +24,8 @@ function UploadSchema { if ($ArtifactsPrefix -ne '') { $schemaName = $ArtifactsPrefix + $schemaName } - Write-Host "Uploading schema '$schemaName' into the Azure Integration Account '$Name'" + Write-Verbose "Uploading schema '$schemaName' into the Azure Integration Account '$Name'..." - ## Check if the schema already exists $existingSchema = $null try { Write-Verbose "Checking if the schema '$schemaName' already exists in the Azure Integration Account '$Name'" @@ -34,7 +33,7 @@ function UploadSchema { } catch { if ($_.Exception.Message.Contains('could not be found')) { - Write-Verbose "No schema '$schemaName' could not be found in Azure Integration Account '$Name'" + Write-Warning "No schema '$schemaName' could not be found in Azure Integration Account '$Name'" } else { throw $_.Exception @@ -43,18 +42,16 @@ function UploadSchema { try { if ($existingSchema -eq $null) { - # Create the schema - Write-Verbose "Creating schema '$schemaName' in Azure Integration Account '$Name'" + Write-Verbose "Creating schema '$schemaName' in Azure Integration Account '$Name'..." $createdSchema = New-AzIntegrationAccountSchema -ResourceGroupName $ResourceGroupName -Name $Name -SchemaName $schemaName -SchemaFilePath $schema.FullName -ErrorAction Stop - Write-Verbose ($createdSchema | Format-List -Force | Out-String) + Write-Debug ($createdSchema | Format-List -Force | Out-String) } else { - # Update the schema - Write-Verbose "Updating schema '$schemaName' in Azure Integration Account '$Name'" + Write-Verbose "Updating schema '$schemaName' in Azure Integration Account '$Name'..." $updatedSchema = Set-AzIntegrationAccountSchema -ResourceGroupName $ResourceGroupName -Name $Name -SchemaName $schemaName -SchemaFilePath $schema.FullName -ErrorAction Stop -Force - Write-Verbose ($updatedSchema | Format-List -Force | Out-String) + Write-Debug ($updatedSchema | Format-List -Force | Out-String) } - Write-Host "Schema '$schemaName' has been uploaded into the Azure Integration Account '$Name'" + Write-Host "Schema '$schemaName' has been uploaded into the Azure Integration Account '$Name'" -ForegroundColor Green } catch { Write-Error "Failed to upload schema '$schemaName' in Azure Integration Account '$Name': '$($_.Exception.Message)'" @@ -69,7 +66,6 @@ else { if ($SchemasFolder -ne '' -and $SchemaFilePath -eq '') { foreach ($schema in Get-ChildItem($schemasFolder) -File) { UploadSchema -Schema $schema - Write-Host '----------' } } elseif ($schemasFolder -eq '' -and $SchemaFilePath -ne '') { diff --git a/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 b/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 index fcb0c505..f480461f 100644 --- a/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 +++ b/src/Arcus.Scripting.KeyVault/Scripts/Get-AzKeyVaultAccessPolicies.ps1 @@ -13,7 +13,7 @@ if($resourceGroupName -eq '') { } $armAccessPolicies = @() -if($keyVault) { +if($keyVault) { Write-Verbose "Found Azure Key Vault '$keyVaultName'" $keyVaultAccessPolicies = $keyVault.accessPolicies @@ -33,13 +33,13 @@ if($keyVault) { } Write-Verbose "Azure Key Vault access policy successfully retrieved for TenantId: $($armAccessPolicy.tenantId) and ObjectId: $($armAccessPolicy.ObjectId)" - Write-Verbose ($armAccessPolicyPermissions | Format-list | Out-String) + Write-Debug ($armAccessPolicyPermissions | Format-list | Out-String) $armAccessPolicy | Add-Member -MemberType NoteProperty -Name permissions -Value $armAccessPolicyPermissions $armAccessPolicies += $armAccessPolicy } - Write-Host "Successfully retrieved Azure Key Vault access policies" + Write-Host "Successfully retrieved Azure Key Vault access policies" -ForegroundColor Green } } else { Write-Warning "Azure Key Vault '$keyVaultName' could not be found, please check if the provided vault name and/or resource group name is correct." diff --git a/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 b/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 index c9b91f84..58ce454b 100644 --- a/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 +++ b/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 @@ -34,4 +34,4 @@ if ($Expires -ne $null) { } $version = $secret.Version -Write-Host "Azure Key Vault Secret '$SecretName' (Version: '$version') has been created." +Write-Host "Azure Key Vault Secret '$SecretName' (Version: '$version') has been created" -ForegroundColor Green diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 index 4a1bc5fc..cdd45a50 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 @@ -18,20 +18,20 @@ try{ $fullUrl = . $PSScriptRoot\Get-AzLogicAppResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -Action "disable" - Write-Host "Attempting to disable $LogicAppName" + Write-Verbose "Attempting to disable Azure Logic App '$LogicAppName'..." $params = @{ Method = 'Post' Headers = @{ - 'authorization'="Bearer $AccessToken" + 'authorization'="Bearer $AccessToken" } URI = $fullUrl } $web = Invoke-WebRequest @params -ErrorAction Stop - Write-Host "Successfully disabled $LogicAppName" + Write-Host "Successfully disabled Azure Logic App '$LogicAppName'" -ForegroundColor Green } catch { - Write-Warning "Failed to disable $LogicAppName" + Write-Warning "Failed to disable Azure Logic App '$LogicAppName'" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" -} + Write-Debug "Error: $ErrorMessage" +} \ No newline at end of file diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 index 893557a0..8bdcfc70 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 @@ -18,15 +18,15 @@ function ExecuteStopType() { [string][parameter(Mandatory = $true)]$stopType ) BEGIN { - Write-Host("> Executing StopType '$stopType' for Logic App '$LogicAppName' in resource group '$ResourceGroupName'") + Write-Verbose "Executing StopType '$stopType' for Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'..." If ($stopType -Match "Immediate") { try { Disable-AzLogicApp -EnvironmentName $EnvironmentName -SubscriptionId $Global:subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -AccessToken $Global:accessToken } catch { - Write-Warning "Failed to disable $LogicAppName" + Write-Warning "Failed to disable Azure Logic App '$LogicAppName'" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" + Write-Debug "Error: $ErrorMessage" } } ElseIf ($stopType -Match "None") { @@ -46,10 +46,10 @@ function ExecuteCheckType() { [System.Array][parameter(Mandatory = $true)]$batch ) BEGIN { - Write-Host("> Executing CheckType '$($batch.checkType)' for batch '$($batch.description)' in resource group '$ResourceGroupName'") - If ($batch.checkType -Match "NoWaitingOrRunningRuns") { + Write-Verbose "Executing CheckType '$($batch.checkType)' for batch '$($batch.description)' in resource group '$ResourceGroupName'..." + if ($batch.checkType -Match "NoWaitingOrRunningRuns") { Write-Host "Executing Check 'NoWaitingOrRunningRuns'" - If ($batch.logicApps.Length -gt 0 ) { + if ($batch.logicApps.Length -gt 0 ) { $batch.logicApps | ForEach-Object { $logicApp = $_; if($ResourcePrefix.Length -gt 0){ @@ -61,35 +61,35 @@ function ExecuteCheckType() { $WaitingRunsCount = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $logicApp -ErrorAction Stop | Where-Object Status -eq "Waiting" | Measure-Object | ForEach-Object { $_.Count } if ($RunningRunsCount -ne 0 -and $WaitingRunsCount -ne 0) { while ($RunningRunsCount -ne 0 -and $WaitingRunsCount -ne 0) { - Write-Host "Logic App '$logicApp' has Running and/or Waiting Runs, waiting 10 seconds and checking again.." - Write-Host "Number of running runs: $RunningRunsCount" - Write-Host "Number of waiting runs: $WaitingRunsCount" + Write-Verbose "Azure Logic App '$logicApp' has Running and/or Waiting Runs, waiting 10 seconds and checking again..." + Write-Debug "Number of running runs: $RunningRunsCount" + Write-Debug "Number of waiting runs: $WaitingRunsCount" Start-Sleep -Second 10 $RunningRunsCount = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $logicApp -ErrorAction Stop | Where-Object Status -eq "Running" | Measure-Object | ForEach-Object { $_.Count } $WaitingRunsCount = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $logicApp -ErrorAction Stop | Where-Object Status -eq "Waiting" | Measure-Object | ForEach-Object { $_.Count } if ($RunningRunsCount -eq 0 -and $WaitingRunsCount -eq 0) { - Write-Host("Found no more waiting or running runs for '$logicApp', executing stopType for Logic App") + Write-Verbose "Found no more waiting or running runs for Azure Logic App '$logicApp', executing stopType for Logic App" ExecuteStopType -resourceGroupName $ResourceGroupName -LogicAppName $logicApp -stopType $batch.stopType } } - }else{ - Write-Host("Found no more waiting or running runs for '$logicApp', executing stopType for Logic App") + } else{ + Write-Verbose "Found no more waiting or running runs for Azure Logic App '$logicApp', executing stopType for Logic App" ExecuteStopType -resourceGroupName $ResourceGroupName -LogicAppName $logicApp -stopType $batch.stopType } - Write-Host("> Check 'NoWaitingOrRunningRuns' executed successfully on '$logicApp'") + Write-Host "Check 'NoWaitingOrRunningRuns' executed successfully on Azure Logic APp '$logicApp'" -ForegroundColor Green } catch { - Write-Warning "Failed to perform check 'NoWaitingOrRunningRuns' for $logicApp" + Write-Warning "Failed to perform check 'NoWaitingOrRunningRuns' for Azure Logic App '$logicApp'" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" - } + Write-Debug "Error: $ErrorMessage" + } } } else { - Write-Warning "No Logic Apps specified." + Write-Warning "No Azure Logic Apps specified to disable" } } - ElseIf ($batch.checkType -Match "None") { + elseIf ($batch.checkType -Match "None") { Write-Host "Executing Check 'None' => peforming no check and executing stopType" $batch.logicApps | ForEach-Object { $logicApp = $_; @@ -100,7 +100,7 @@ function ExecuteCheckType() { } } else { - Write-Warning "CheckType '$batch.checkType' has no known implementation, performing no check or stop on the Logic App.." + Write-Warning "CheckType '$batch.checkType' has no known implementation, performing no check or stop on the Azure Logic App '$logicApp' in resource group '$ResourceGroupName'..." } } } @@ -119,12 +119,9 @@ if($json.Length -gt 0){ $json | ForEach-Object { $batch = $_; $batchDescription = $batch.description - Write-Host("Executing batch: '$batchDescription'") - Write-Host("====================================") + Write-Verbose "Executing batch: '$batchDescription'" #Call the ExecuteCheckType function which will call the ExecuteStopType function after a check for a Logic App has completed ExecuteCheckType -resourceGroupName $ResourceGroupName -batch $batch - ## Wrap up - Write-Host("-> Batch: '$batchDescription' has been executed") - Write-Host("") + Write-Host "Batch: '$batchDescription' has been executed" -ForegroundColor Green } diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicApp.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicApp.ps1 index a55e30eb..c16df2cf 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicApp.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicApp.ps1 @@ -18,20 +18,20 @@ try{ $fullUrl = . $PSScriptRoot\Get-AzLogicAppResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -Action enable - Write-Host "Attempting to enable $LogicAppName" + Write-Verbose "Attempting to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'..." $params = @{ Method = 'Post' Headers = @{ - 'authorization'="Bearer $AccessToken" + 'authorization'="Bearer $AccessToken" } URI = $fullUrl } $web = Invoke-WebRequest @params -ErrorAction Stop - Write-Host "Successfully enabled $LogicAppName" + Write-Host "Successfully enabled Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green } catch { - Write-Warning "Failed to enable $LogicAppName" + Write-Warning "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" + Write-Debug "Error: $ErrorMessage" } diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 index 3ba15400..af8db433 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 @@ -17,9 +17,9 @@ function ReverseStopType() { [System.Array][parameter(Mandatory = $true)]$batch ) BEGIN { - Write-Host("> Reverting stopType '$($batch.stopType)' for batch '$($batch.description)' in resource group '$ResourceGroupName'") - If ($batch.stopType -Match "Immediate") { - If ($batch.logicApps.Length -gt 0 ) { + Write-Verbose "Reverting stopType '$($batch.stopType)' for batch '$($batch.description)' in resource group '$ResourceGroupName'" + if ($batch.stopType -Match "Immediate") { + if ($batch.logicApps.Length -gt 0 ) { $batch.logicApps | ForEach-Object { $LogicAppName = $_; if($ResourcePrefix.Length -gt 0){ @@ -29,21 +29,21 @@ function ReverseStopType() { Enable-AzLogicApp -EnvironmentName $EnvironmentName -SubscriptionId $Global:subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -AccessToken $Global:accessToken } catch { - Write-Warning "Failed to enable $LogicAppName" + Write-Warning "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" + Write-Debug "Error: $ErrorMessage" } } } else { - Write-Warning "No Logic Apps specified." + Write-Warning "No Azure Logic Apps specified to enable" } } - ElseIf ($batch.stopType -Match "None") { + elseIf ($batch.stopType -Match "None") { Write-Host "StopType equals 'None', performing no enable action on the Logic App(s)" } else { - Write-Warning "StopType '$($batch.stopType)' has no known implementation, doing nothing.." + Write-Warning "StopType '$($batch.stopType)' has no known implementation, doing nothing" } } } @@ -58,12 +58,9 @@ if($json.Length -gt 0){ $json | ForEach-Object { $batch = $_; $batchDescription = $batch.description - Write-Host("Executing batch: '$batchDescription'") - Write-Host("====================================") + Write-Verbose "Executing batch: '$batchDescription'" #Call the ReverseStopType function which will revert the executed stopType ReverseStopType -resourceGroupName $resourceGroupName -batch $batch - ## Wrap up - Write-Host("-> Batch: '$batchDescription' has been executed") - Write-Host("") + Write-Host "Batch: '$batchDescription' has been executed" -ForegroundColor Green } \ No newline at end of file diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Get-AzLogicAppResourceManagementUrl.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Get-AzLogicAppResourceManagementUrl.ps1 index 560399ff..dd4a8c9b 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Get-AzLogicAppResourceManagementUrl.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Get-AzLogicAppResourceManagementUrl.ps1 @@ -8,18 +8,18 @@ param( ) -try{ - $resourceManagerUrl = "" - +try { + $resourceManagerUrl = "" + $environments = (Get-AzEnvironment).Name - if($EnvironmentName -notin $environments){ + if ($EnvironmentName -notin $environments) { $supportedEnvironments = "" - foreach($env in $environments){ - if($supportedEnvironments.Length -eq 0) { + foreach ($env in $environments) { + if ($supportedEnvironments.Length -eq 0) { $supportedEnvironments += $env } - else{ + else { $supportedEnvironments += ", " + $env } } @@ -34,8 +34,7 @@ try{ return $fullUrl } catch { - Write-Warning "Failed to define the resource management endpoint." + Write-Warning "Failed to define the resource management endpoint (Environment: '$EnvironmentName', SubscriptionId: '$SubscriptionId', ResourceGroup: '$ResourceGroupName', LogicApp: '$LogicAppName')" $ErrorMessage = $_.Exception.Message - Write-Warning "Error: $ErrorMessage" -} - + Write-Debug "Error: $ErrorMessage" +} \ No newline at end of file From 2d2e17ae0d6c3f724464089414eecf2cd7c8e68e Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 09:22:10 +0100 Subject: [PATCH 02/10] pr-fix: more flexible logic app unit tests assertions --- .../Arcus.Scripting.LogicApps.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 index 35c042df..651acabf 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 @@ -33,7 +33,7 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to enable $logicAppName" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to enable Azure Logic App '$logicAppName'" } Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } @@ -107,7 +107,7 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to disable $logicAppName" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to disable Azure Logic App '$logicAppName'" } Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } From 5efe387e0e8ff13e25fd5822de4ae2a528677725 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 09:31:53 +0100 Subject: [PATCH 03/10] pr-fix: correct apim unit tests assertions --- .../Arcus.Scripting.Management.tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 index e10860f0..2f41a513 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 @@ -23,7 +23,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Remove-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "API Management instance with name '$Name' is not listed as a soft deleted service and therefore it cannot be removed or restored" + } | Should -Throw -ExpectedMessage "Azure API Management service '$Name' is not listed as a soft deleted service and therefore it cannot be removed or restored" # Assert Assert-VerifiableMock @@ -57,7 +57,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Remove-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "The soft deleted API Management instance '$Name' could not be removed. Details: some error" + } | Should -Throw -ExpectedMessage "The soft deleted Azure API Management service '$Name' could not be removed. Details: some error" # Assert Assert-VerifiableMock @@ -163,7 +163,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Restore-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "The soft deleted API Management instance '$Name' could not be restored. Details: some error" + } | Should -Throw -ExpectedMessage "The soft deleted Azure API Management service '$Name' could not be restored. Details: some error" # Assert Assert-VerifiableMock From 4cdb578a018eed3bf62619f5f390fccc42710a0d Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 09:44:48 +0100 Subject: [PATCH 04/10] Revert "pr-fix: correct apim unit tests assertions" This reverts commit 5efe387e0e8ff13e25fd5822de4ae2a528677725. --- .../Arcus.Scripting.Management.tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 index 2f41a513..e10860f0 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.Management.tests.ps1 @@ -23,7 +23,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Remove-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "Azure API Management service '$Name' is not listed as a soft deleted service and therefore it cannot be removed or restored" + } | Should -Throw -ExpectedMessage "API Management instance with name '$Name' is not listed as a soft deleted service and therefore it cannot be removed or restored" # Assert Assert-VerifiableMock @@ -57,7 +57,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Remove-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "The soft deleted Azure API Management service '$Name' could not be removed. Details: some error" + } | Should -Throw -ExpectedMessage "The soft deleted API Management instance '$Name' could not be removed. Details: some error" # Assert Assert-VerifiableMock @@ -163,7 +163,7 @@ InModuleScope Arcus.Scripting.Management { # Act { Restore-AzApiManagementSoftDeletedService -Name $Name - } | Should -Throw -ExpectedMessage "The soft deleted Azure API Management service '$Name' could not be restored. Details: some error" + } | Should -Throw -ExpectedMessage "The soft deleted API Management instance '$Name' could not be restored. Details: some error" # Assert Assert-VerifiableMock From 0d0ace878a362023aaddb41b1bc6c442dd5fa856 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 10:21:00 +0100 Subject: [PATCH 05/10] pr-fix: correct logic app unit test assertions --- .../Arcus.Scripting.LogicApps.tests.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 index 651acabf..58789aff 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 @@ -9,7 +9,7 @@ InModuleScope Arcus.Scripting.LogicApps { $resourceGroupName = "codit-arcus-scripting" $logicAppName = "arc-dev-we-rcv-unknown-http" $errorContent = "{""error"":{""code"":""ResourceNotFound"",""message"":""Unable to find the resource Microsoft.Logic/workflows/$logicAppName within resourcegroup codit-arcus-scripting.""}}" - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to enable $logicAppName" } + Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } Mock Invoke-WebRequest -MockWith { $status = [System.Net.WebExceptionStatus]::ConnectionClosed @@ -33,7 +33,7 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to enable Azure Logic App '$logicAppName'" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } @@ -83,7 +83,7 @@ InModuleScope Arcus.Scripting.LogicApps { $resourceGroupName = "codit-arcus-scripting" $logicAppName = "arc-dev-we-rcv-unknown-http" $errorContent = "{""error"":{""code"":""ResourceNotFound"",""message"":""Unable to find the resource Microsoft.Logic/workflows/$logicAppName within resourcegroup codit-arcus-scripting.""}}" - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to disable $logicAppName" } + Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } Mock Invoke-WebRequest -MockWith { $status = [System.Net.WebExceptionStatus]::ConnectionClosed @@ -107,7 +107,7 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to disable Azure Logic App '$logicAppName'" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } From 459b1eba5ee133cd04c6e8b47d4ed5eefea38647 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 10:35:05 +0100 Subject: [PATCH 06/10] pr-fix: correct logic app assertions in unit tests --- .../Arcus.Scripting.LogicApps.tests.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 index 58789aff..c852ce6d 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 @@ -9,8 +9,8 @@ InModuleScope Arcus.Scripting.LogicApps { $resourceGroupName = "codit-arcus-scripting" $logicAppName = "arc-dev-we-rcv-unknown-http" $errorContent = "{""error"":{""code"":""ResourceNotFound"",""message"":""Unable to find the resource Microsoft.Logic/workflows/$logicAppName within resourcegroup codit-arcus-scripting.""}}" - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } + Mock Write-Warning -MockWith { } + Mock Write-Debug -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } Mock Invoke-WebRequest -MockWith { $status = [System.Net.WebExceptionStatus]::ConnectionClosed $response = New-Object -type 'System.Net.HttpWebResponse' @@ -33,8 +33,8 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } + Assert-MockCalled Write-Debug -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } Context "Enable Logic Apps with configuration" { @@ -83,8 +83,8 @@ InModuleScope Arcus.Scripting.LogicApps { $resourceGroupName = "codit-arcus-scripting" $logicAppName = "arc-dev-we-rcv-unknown-http" $errorContent = "{""error"":{""code"":""ResourceNotFound"",""message"":""Unable to find the resource Microsoft.Logic/workflows/$logicAppName within resourcegroup codit-arcus-scripting.""}}" - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } - Mock Write-Warning -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } + Mock Write-Warning -MockWith { } + Mock Write-Debug -MockWith { } -ParameterFilter {$Message -like "Error: $errorContent" } Mock Invoke-WebRequest -MockWith { $status = [System.Net.WebExceptionStatus]::ConnectionClosed $response = New-Object -type 'System.Net.HttpWebResponse' @@ -107,8 +107,8 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to disable Azure Logic App '$LogicAppName'" } + Assert-MockCalled Write-Debug -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } } Context "Disable Logic Apps with configuration" { From f37b950854825cc00810311a00d1fbd5be45f347 Mon Sep 17 00:00:00 2001 From: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 11:24:02 +0100 Subject: [PATCH 07/10] Update src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 Co-authored-by: Pim Simons <32359437+pim-simons@users.noreply.github.com> --- .../Scripts/Add-AzADAppRoleAssignment.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 b/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 index f28ed3d7..d512d106 100644 --- a/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 +++ b/src/Arcus.Scripting.ActiveDirectory/Scripts/Add-AzADAppRoleAssignment.ps1 @@ -38,7 +38,7 @@ try { $adApplication.AppRole += $newRole Update-AzADApplication -ObjectId $adApplication.Id -AppRole $adApplication.AppRole - Write-Host "Added role '$Role' to Active Directory Application '$($adApplication.DisplayName)e'" + Write-Host "Added role '$Role' to Active Directory Application '$($adApplication.DisplayName)'" $currentAppRole = $newRole } else { From 6fc7c974b5ec55e8cd263acff72a048e647fc876 Mon Sep 17 00:00:00 2001 From: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Date: Mon, 26 Dec 2022 11:24:25 +0100 Subject: [PATCH 08/10] Update src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 Co-authored-by: Pim Simons <32359437+pim-simons@users.noreply.github.com> --- .../Scripts/Disable-AzLogicAppsFromConfig.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 index 8bdcfc70..e8f16d2b 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicAppsFromConfig.ps1 @@ -76,7 +76,7 @@ function ExecuteCheckType() { Write-Verbose "Found no more waiting or running runs for Azure Logic App '$logicApp', executing stopType for Logic App" ExecuteStopType -resourceGroupName $ResourceGroupName -LogicAppName $logicApp -stopType $batch.stopType } - Write-Host "Check 'NoWaitingOrRunningRuns' executed successfully on Azure Logic APp '$logicApp'" -ForegroundColor Green + Write-Host "Check 'NoWaitingOrRunningRuns' executed successfully on Azure Logic App '$logicApp'" -ForegroundColor Green } catch { Write-Warning "Failed to perform check 'NoWaitingOrRunningRuns' for Azure Logic App '$logicApp'" From 636e1e7f7d528a907fc039d11ff3534e5d451542 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Tue, 27 Dec 2022 07:11:35 +0100 Subject: [PATCH 09/10] pr-fix: update related documentation --- .../powershell/azure-api-management.md | 70 +++--- .../powershell/azure-data-factory.md | 4 +- .../03-Features/powershell/azure-devops.md | 9 +- .../powershell/azure-integration-account.md | 73 ------- .../03-Features/powershell/azure-key-vault.md | 20 +- .../powershell/azure-logic-apps.md | 206 ++++++------------ .../Create-AzApiManagementApiOperation.ps1 | 2 +- .../Scripts/Set-AzDataFactoryTriggerState.ps1 | 57 ++--- .../Scripts/Set-AzKeyVaultSecretFromFile.ps1 | 6 +- .../Scripts/Disable-AzLogicApp.ps1 | 6 +- .../Scripts/Enable-AzLogicAppsFromConfig.ps1 | 2 +- 11 files changed, 137 insertions(+), 318 deletions(-) diff --git a/docs/preview/03-Features/powershell/azure-api-management.md b/docs/preview/03-Features/powershell/azure-api-management.md index b51750a0..0594d1fe 100644 --- a/docs/preview/03-Features/powershell/azure-api-management.md +++ b/docs/preview/03-Features/powershell/azure-api-management.md @@ -39,12 +39,8 @@ PS> Backup-AzApiManagementService ` -StorageAccountName "my-storage-account" ` -ServiceName "my-service" ` -ContainerName "my-target-blob-container" -# Getting Azure storage account key.. -# Got Azure storage key! -# Create new Azure storage context with storage key... -# New Azure storage context with storage key created! -# Start backing up API management service... -# API management service is backed-up! +# New Azure storage context for storage account 'my-storage-account' with storage key created! +# Azure API management service 'my-service' in resource group 'my-resource-group' is backed-up! ``` ## Creating a new API operation in the Azure API Management instance @@ -75,7 +71,7 @@ PS> Create-AzApiManagementApiOperation ` -OperationId $OperationId ` -Method $Method ` -UrlTemplate $UrlTemplate -# New API operation '$OperationName' on Azure API Management instance was added. +# New API operation '$OperationName' was added on Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` Creates a new API operation on the Azure API Management instance with using a specific operation policy. @@ -91,12 +87,13 @@ PS> Create-AzApiManagementApiOperation ` -OperationName $OperationName ` -Description $Description ` -PolicyFilePath $PolicyFilePath -# New API operation '$OperationName' on API Management instance was added. +# New API operation '$OperationName' was added on Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' +# Updated policy of the operation '$OperationId' in API '$ApiId' of the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Creating a new user in an Azure API Management service -Signup or invite a new user in an existing Azure API Management instance. +Sign-up or invite a new user in an existing Azure API Management instance. | Parameter | Mandatory | Description | | ------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -125,8 +122,7 @@ PS> Create-AzApiManagementUserAccount ` -FirstName $FirstName ` -LastName $LastName ` -MailAddress $MailAddress -# Attempting to invite $FirstName $LastName ($MailAddress) -# Invitation has been sent to FirstName $LastName ($MailAddress) +# Invitation has been sent to $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` Invite a new user in an existing Azure API Management instance and specify a UserId. @@ -139,8 +135,7 @@ PS> Create-AzApiManagementUserAccount ` -LastName $LastName ` -MailAddress $MailAddress ` -UserId $UserId -# Attempting to invite $FirstName $LastName ($MailAddress) -# Invitation has been sent to FirstName $LastName ($MailAddress) +# Invitation has been sent to $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` Invite a new user in an existing Azure API Management instance and include a note. @@ -153,8 +148,7 @@ PS> Create-AzApiManagementUserAccount ` -LastName $LastName ` -MailAddress $MailAddress ` -Note $Note -# Attempting to invite $FirstName $LastName ($MailAddress) -# Invitation has been sent to FirstName $LastName ($MailAddress) +# Invitation has been sent to $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` Invite a new user in an existing Azure API Management instance and send a notification. @@ -167,8 +161,7 @@ PS> Create-AzApiManagementUserAccount ` -LastName $LastName ` -MailAddress $MailAddress ` -SendNotification -# Attempting to invite $FirstName $LastName ($MailAddress) -# Invitation has been sent to FirstName $LastName ($MailAddress) +# Invitation has been sent to $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` Signup a new user in an existing Azure API Management instance. @@ -181,8 +174,7 @@ PS> Create-AzApiManagementUserAccount ` -LastName $LastName ` -MailAddress $MailAddress ` -ConfirmationType signup -# Attempting to create account for FirstName $LastName ($MailAddress) -# Account has been created for FirstName $LastName ($MailAddress) +# Account has been created for $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' # Since no password was provided, one has been generated. Please advise the user to change this password the first time logging in ``` @@ -197,8 +189,7 @@ PS> Create-AzApiManagementUserAccount ` -MailAddress $MailAddress ` -Password $Password ` -ConfirmationType signup -# Attempting to create account for FirstName $LastName ($MailAddress) -# Account has been created for FirstName $LastName ($MailAddress) +# Account has been created for $FirstName $LastName ($mailAddress) for Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Removing a user from an Azure API Management service @@ -222,9 +213,7 @@ PS> Remove-AzApiManagementUserAccount ` -ResourceGroupName $ResourceGroup ` -ServiceName $ServiceName ` -MailAddress $MailAddress -# Retrieving the user account with e-mail '$MailAddress' -# Attempting to remove the user account with e-mail '$MailAddress' and id '1' -# Removed the user account with e-mail '$MailAddress' and id '1' +# Removed the user account with e-mail '$MailAddress' and ID '1' for the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Importing a policy to a product in the Azure API Management instance @@ -244,7 +233,7 @@ PS> Import-AzApiManagementProductPolicy ` -ServiceName $ServiceName ` -ProductId $ProductId ` -PolicyFilePath $PolicyFilePath -# Updating policy of the product '$ProductId' +# Successfully updated the product policy for the Azure API Management service $ServiceName in resource group $ResourceGroupName ``` ## Importing a policy to an API in the Azure API Management instance @@ -264,7 +253,7 @@ PS> Import-AzApiManagementApiPolicy ` -ServiceName $ServiceName ` -ApiId $ApiId ` -PolicyFilePath $PolicyFilePath -# Updating policy of the API '$ApiId' +# Successfully updated API policy for the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Importing a policy to an operation in the Azure API Management instance @@ -286,7 +275,7 @@ PS> Import-AzApiManagementOperationPolicy ` -ApiId $ApiId ` -OperationId $OperationId ` -PolicyFilePath $PolicyFilePath -# Updating policy of the operation '$OperationId' in API '$ApiId' +# USuccessfully updated the operation policy for the Azure API Management service $ServiceName in resource group $ResourceGroupName ``` ## Removing all Azure API Management defaults from the instance @@ -302,9 +291,9 @@ Remove all default API's and products from the Azure API Management instance ('e PS> Remove-AzApiManagementDefaults ` -ResourceGroupName $ResourceGroup ` -ServiceName $ServiceName -# Removing Echo Api... -# Removing Starter product... -# Removing Unlimited product... +# Removed 'echo' API in the Azure API Management service $ServiceName in resource group $ResourceGroupName +# Removed 'starter' product in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' +# Removed 'unlimited' product in the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Restoring an API Management service @@ -330,12 +319,7 @@ PS> Restore-AzApiManagementService ` -ServiceName $ServiceName ` -ContainerName $ContainerName ` -BlobName $BlobName -# Getting Azure storage account key... -# Got Azure storage key! -# Create new Azure storage context with storage key... -# New Azure storage context with storage key created! -# Start restoring up API management service... -# API management service is restored! +# Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' is restored! ``` ## Setting authentication keys to an API in the Azure API Management instance @@ -357,9 +341,9 @@ PS> Set-AzApiManagementApiSubscriptionKey ` -ResourceGroupName $ResourceGroup ` -ServiceName $ServiceName ` -ApiId $ApiId -Write-Host "Using API Management instance '$ServiceName' in resource group '$ResourceGroup'" -Write-Host "Subscription key header 'x-api-key' was assigned" -Write-Host "Subscription key query parameter 'apiKey' was assigned" +# Using API Management instance '$ServiceName' in resource group '$ResourceGroup' +# Subscription key header 'x-api-key' was assigned +# Subscription key query parameter 'apiKey' was assigned ``` **User-defined values** @@ -371,9 +355,8 @@ PS> Set-AzApiManagementApiSubscriptionKey ` -ApiId $ApiId ` -HeaderName "my-api-key" ` -QueryParamName "myApiKey" -Write-Host "Using API Management instance '$ServiceName' in resource group '$ResourceGroup'" -Write-Host "Subscription key header 'my-api-key' was assigned" -Write-Host "Subscription key query parameter 'myApiKey' was assigned" +# Subscription key header 'my-api-key' was assigned for the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' +# Subscription key query parameter 'myApiKey' was assigned for the Azure API Management service '$ServiceName' in resource group '$ResourceGroupName' ``` ## Uploading private certificates to the Azure API Management certificate store @@ -395,6 +378,5 @@ PS> Upload-AzApiManagementCertificate ` -ServiceName "my-api-management-instance" ` -CertificateFilePath "c:\temp\certificate.pfx" ` -CertificatePassword "P@ssw0rd" -# Using API Management instance 'my-api-management-instance' in resource group 'my-resource-group' -# Uploaded private certificate at 'c:\temp\certificate.pfx' +# Uploaded private certificate at 'C:\temp\certificate.pfx' for the Azure API Management service 'my-api-management-instance' in resource group 'my-resource-group' ``` diff --git a/docs/preview/03-Features/powershell/azure-data-factory.md b/docs/preview/03-Features/powershell/azure-data-factory.md index 4c9bc991..82099dc1 100644 --- a/docs/preview/03-Features/powershell/azure-data-factory.md +++ b/docs/preview/03-Features/powershell/azure-data-factory.md @@ -31,7 +31,7 @@ PS> Enable-AzDataFactoryTrigger ` -ResourceGroupName "my-resource-group" ` -DataFactoryName "my-data-factory-name" ` -DataFactoryTriggerName "my-data-factory-trigger-name" -# The trigger 'my-data-factory-trigger-name' has been enabled. +# Started Azure Data Factory trigger 'my-data-factory-trigger-name' of data factory 'my-data-factory-name' in resource group 'my-resource-group' ``` ```powershell @@ -62,7 +62,7 @@ PS> Disable-AzDataFactoryTrigger ` -ResourceGroupName "my-resource-group" ` -DataFactoryName "my-data-factory-name" ` -DataFactoryTriggerName "my-data-factory-trigger-name" -# The trigger 'my-data-factory-trigger-name' has been disabled. +# Stopped Azure Data Factory trigger 'my-data-factory-trigger-name' of data factory 'my-data-factory-name' in resource group 'my-resource-group' ``` ```powershell diff --git a/docs/preview/03-Features/powershell/azure-devops.md b/docs/preview/03-Features/powershell/azure-devops.md index 12170711..3b459364 100644 --- a/docs/preview/03-Features/powershell/azure-devops.md +++ b/docs/preview/03-Features/powershell/azure-devops.md @@ -124,7 +124,7 @@ With default `ArmOutputs` environment variable containing: `"my-variable": "my-v ```powershell PS> Set-AzDevOpsArmOutputsToPipelineVariables -# Get ARM outputs from 'ArmOutputs' environment variable +# Getting ARM outputs from 'ArmOutputs' environment variable... # The pipeline variable my-variable will be updated to value my-value, so it can be used in subsequent tasks of the current job. # ##vso[task.setvariable variable=my-variable]my-value ``` @@ -133,7 +133,7 @@ With custom `MyArmOutputs` environment variable containing: `"my-variable": "my- ```powershell PS> Set-AzDevOpsArmOutputsToPipelineVariables -ArmOutputsEnvironmentVariableName "MyArmOutputs" -# Get ARM outputs from 'MyArmOutputs' environment variable +# Getting ARM outputs from 'MyArmOutputs' environment variable... # The pipeline variable my-variable will be updated to value my-value, so it can be used in subsequent tasks of the current job. # ##vso[task.setvariable variable=my-variable]my-value ``` @@ -176,10 +176,11 @@ Saves/retains a specific Azure DevOps pipeline run. PS> Save-AzDevOpsBuild ` -ProjectId $(System.TeamProjectId) ` -BuildId $(Build.BuildId) -# The variables $(System.TeamProjectId) and $(Build.BuildId) are predefined Azure DevOps variables -# Information on them can be found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml +# Saved Azure DevOps build with build ID $BuildId in project $ProjectId ``` +> 💡 The variables $(System.TeamProjectId) and $(Build.BuildId) are predefined Azure DevOps variables. Information on them can be found here: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml + **Azure DevOps Example** This function is intended to be used from an Azure DevOps pipeline. Internally, it uses some predefined Azure DevOps variables. One of the environment variables that is used, is the `SYSTEM_ACCESSTOKEN` variable. However, due to safety reasons this variable is not available out-of-the box. diff --git a/docs/preview/03-Features/powershell/azure-integration-account.md b/docs/preview/03-Features/powershell/azure-integration-account.md index 5d63bb1f..4ad387cf 100644 --- a/docs/preview/03-Features/powershell/azure-integration-account.md +++ b/docs/preview/03-Features/powershell/azure-integration-account.md @@ -34,7 +34,6 @@ PS> Set-AzIntegrationAccountSchemas ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -SchemaFilePath "C:\Schemas\MySchema.xsd" -# Uploading schema 'MySchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'MySchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -45,7 +44,6 @@ PS> Set-AzIntegrationAccountSchemas ` -Name 'my-integration-account' ` -SchemaFilePath "C:\Schemas\MySchema.xsd" ` -RemoveFileExtensions -# Uploading schema 'MySchema' into the Azure Integration Account 'my-integration-account' # Schema 'MySchema' has been uploaded into the Azure Integration Account 'my-integration-account' ``` Uploading a *single schema* into an Integration Account and set add a prefix to the name of the schema within the Integration Account. @@ -55,7 +53,6 @@ PS> Set-AzIntegrationAccountSchemas ` -Name 'my-integration-account' ` -SchemaFilePath "C:\Schemas\MySchema.xsd" ` -ArtifactsPrefix 'dev-' -# Uploading schema 'dev-MySchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'dev-MySchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -65,12 +62,8 @@ PS> Set-AzIntegrationAccountSchemas ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -SchemasFolder "C:\Schemas" -# Uploading schema 'MyFirstSchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'MyFirstSchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading schema 'MySecondSchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'MySecondSchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all schemas* located in a specific folder into an Integration Account and remove the file-extension. @@ -80,12 +73,8 @@ PS> Set-AzIntegrationAccountSchemas ` -Name 'my-integration-account' ` -SchemasFolder "C:\Schemas" ` -RemoveFileExtensions -# Uploading schema 'MyFirstSchema' into the Azure Integration Account 'my-integration-account' # Schema 'MyFirstSchema' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading schema 'MySecondSchema' into the Azure Integration Account 'my-integration-account' # Schema 'MySecondSchema' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all schemas* located in a specific folder into an Integration Account and set add a prefix to the name of the schemas. @@ -95,15 +84,10 @@ PS> Set-AzIntegrationAccountSchemas ` -Name 'my-integration-account' ` -SchemasFolder "C:\Schemas" ` -ArtifactsPrefix 'dev-' -# Uploading schema 'dev-MyFirstSchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'dev-MyFirstSchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading schema 'dev-MySecondSchema.xsd' into the Azure Integration Account 'my-integration-account' # Schema 'dev-MySecondSchema.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` - ## Uploading maps into an Azure Integration Account Upload/update a single, or multiple maps into an Azure Integration Account. @@ -126,7 +110,6 @@ PS> Set-AzIntegrationAccountMaps ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -MapFilePath "C:\Maps\MyMap.xslt" -# Uploading map 'MyMap.xslt' into the Azure Integration Account 'my-integration-account' # Map 'MyMap.xslt' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -137,7 +120,6 @@ PS> Set-AzIntegrationAccountMaps ` -Name 'my-integration-account' ` -MapFilePath "C:\Maps\MyMap.xslt" ` -RemoveFileExtensions -# Uploading map 'MyMap' into the Azure Integration Account 'my-integration-account' # Map 'MyMap' has been uploaded into the Azure Integration Account 'my-integration-account' ``` Uploading a *single map* into an Integration Account and set add a prefix to the name of the schema within the Integration Account. @@ -147,7 +129,6 @@ PS> Set-AzIntegrationAccountMaps ` -Name 'my-integration-account' ` -MapFilePath "C:\Maps\MyMap.xslt" ` -ArtifactsPrefix 'dev-' -# Uploading map 'dev-MyMap.xsd' into the Azure Integration Account 'my-integration-account' # Map 'dev-MyMap.xsd' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -157,12 +138,8 @@ PS> Set-AzIntegrationAccountMaps ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -MapsFolder "C:\Maps" -# Uploading map 'MyFirstMap.xslt' into the Azure Integration Account 'my-integration-account' # Map 'MyFirstMap.xslt' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading map 'MySecondMap.xslt' into the Azure Integration Account 'my-integration-account' # Map 'MySecondMap.xslt' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all maps* located in a specific folder into an Integration Account and remove the file-extension. @@ -172,12 +149,8 @@ PS> Set-AzIntegrationAccountMaps ` -Name 'my-integration-account' ` -MapsFolder "C:\Maps" ` -RemoveFileExtensions -# Uploading map 'MyFirstMap' into the Azure Integration Account 'my-integration-account' # Map 'MyFirstMap' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading map 'MySecondMap' into the Azure Integration Account 'my-integration-account' # Map 'MySecondMap' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all maps* located in a specific folder into an Integration Account and set add a prefix to the name of the maps. @@ -187,12 +160,8 @@ PS> Set-AzIntegrationAccountMaps ` -Name 'my-integration-account' ` -MapsFolder "C:\Maps" ` -ArtifactsPrefix 'dev-' -# Uploading map 'dev-MyFirstMap.xslt' into the Azure Integration Account 'my-integration-account' # Map 'dev-MyFirstMap.xslt' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading map 'dev-MySecondMap.xslt' into the Azure Integration Account 'my-integration-account' # Map 'dev-MySecondMap.xslt' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` ## Uploading assemblies into an Azure Integration Account @@ -215,7 +184,6 @@ PS> Set-AzIntegrationAccountAssemblies ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -AssemblyFilePath "C:\Assemblies\MyAssembly.dll" -# Uploading assembly 'MyAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'MyAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -226,7 +194,6 @@ PS> Set-AzIntegrationAccountAssemblies ` -Name 'my-integration-account' ` -AssemblyFilePath "C:\Assemblies\MyAssembly.dll" ` -ArtifactsPrefix 'dev-' -# Uploading assembly 'dev-MyAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'dev-MyAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -236,12 +203,8 @@ PS> Set-AzIntegrationAccountAssemblies ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -AssembliesFolder "C:\Assemblies" -# Uploading assembly 'MyFirstAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'MyFirstAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading assembly 'MySecondAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'MySecondAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all assemblies* located in a specific folder into an Integration Account and set add a prefix to the name of the assemblies. @@ -251,12 +214,8 @@ PS> Set-AzIntegrationAccountAssemblies ` -Name 'my-integration-account' ` -AssembliesFolder "C:\Assemblies" ` -ArtifactsPrefix 'dev-' -# Uploading assembly 'dev-MyFirstAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'dev-MyFirstAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading assembly 'dev-MySecondAssembly.dll' into the Azure Integration Account 'my-integration-account' # Assembly 'dev-MySecondAssembly.dll' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` ## Uploading certificates into an Azure Integration Account @@ -284,7 +243,6 @@ PS> Set-AzIntegrationAccountCertificates ` -Name 'my-integration-account' ` -CertificateType 'Public' ` -CertificateFilePath "C:\Certificates\MyCertificate.cer" -# Uploading certificate 'MyCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'MyCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -296,7 +254,6 @@ PS> Set-AzIntegrationAccountCertificates ` -CertificateType 'Public' ` -CertificateFilePath "C:\Certificates\MyCertificate.cer" ` -ArtifactsPrefix 'dev-' -# Uploading certificate 'dev-MyCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'dev-MyCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -307,12 +264,8 @@ PS> Set-AzIntegrationAccountCertificates ` -Name 'my-integration-account' ` -CertificateType 'Public' ` -CertificatesFolder "C:\Certificates" -# Uploading certificate 'MyFirstCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'MyFirstCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading certificate 'MySecondCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'MySecondCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all public assemblies* located in a specific folder into an Integration Account and set add a prefix to the name of the certificates. @@ -323,12 +276,8 @@ PS> Set-AzIntegrationAccountCertificates ` -CertificateType 'Public' ` -CertificatesFolder "C:\Certificates" ` -ArtifactsPrefix 'dev-' -# Uploading certificate 'dev-MyFirstCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'dev-MyFirstCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading certificate 'dev-MySecondCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'dev-MySecondCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading a *single private certificate* into an Integration Account. @@ -341,7 +290,6 @@ PS> Set-AzIntegrationAccountCertificates ` -KeyName 'MyKey' ` -KeyVersion 'MyKeyVersion' ` -KeyVaultId '/subscriptions//resourcegroups//providers/microsoft.keyvault/vaults/' -# Uploading certificate 'MyCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'MyCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -356,7 +304,6 @@ PS> Set-AzIntegrationAccountCertificates ` -KeyName 'MyKey' ` -KeyVersion 'MyKeyVersion' ` -KeyVaultId '/subscriptions//resourcegroups//providers/microsoft.keyvault/vaults/' -# Uploading certificate 'dev-MyCertificate.cer' into the Azure Integration Account 'my-integration-account' # Certificate 'dev-MyCertificate.cer' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -380,7 +327,6 @@ PS> Set-AzIntegrationAccountPartners ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -PartnerFilePath "C:\Partners\MyPartner.json" -# Uploading partner 'MyPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'MyPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -391,7 +337,6 @@ PS> Set-AzIntegrationAccountPartners ` -Name 'my-integration-account' ` -PartnerFilePath "C:\Partners\MyPartner.json" ` -ArtifactsPrefix 'dev-' -# Uploading partner 'dev-MyPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'dev-MyPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -401,12 +346,8 @@ PS> Set-AzIntegrationAccountPartners ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -PartnersFolder "C:\Partners" -# Uploading partner 'MyFirstPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'MyFirstPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading partner 'MySecondPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'MySecondPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all partners* located in a specific folder into an Integration Account and set add a prefix to the name of the partners. @@ -416,12 +357,8 @@ PS> Set-AzIntegrationAccountPartners ` -Name 'my-integration-account' ` -PartnersFolder "C:\Partners" ` -ArtifactsPrefix 'dev-' -# Uploading partner 'dev-MyFirstPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'dev-MyFirstPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading partner 'dev-MySecondPartner.json' into the Azure Integration Account 'my-integration-account' # Partner 'dev-MySecondPartner.json' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` **Partner JSON Example** @@ -477,7 +414,6 @@ PS> Set-AzIntegrationAccountAgreements ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -AgreementFilePath "C:\Agreements\MyAgreement.json" -# Uploading agreement 'MyAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'MyAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -488,7 +424,6 @@ PS> Set-AzIntegrationAccountAgreements ` -Name 'my-integration-account' ` -AgreementFilePath "C:\Agreements\MyAgreement.json" ` -ArtifactsPrefix 'dev-' -# Uploading agreement 'dev-MyAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'dev-MyAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' ``` @@ -498,12 +433,8 @@ PS> Set-AzIntegrationAccountAgreements ` -ResourceGroupName 'my-resource-group' ` -Name 'my-integration-account' ` -AgreementsFolder "C:\Agreements" -# Uploading agreement 'MyFirstAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'MyFirstAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading agreement 'MySecondAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'MySecondAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` Uploading *all agreements* located in a specific folder into an Integration Account and set add a prefix to the name of the agreements. @@ -513,12 +444,8 @@ PS> Set-AzIntegrationAccountAgreements ` -Name 'my-integration-account' ` -AgreementsFolder "C:\Agreements" ` -ArtifactsPrefix 'dev-' -# Uploading agreement 'dev-MyFirstAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'dev-MyFirstAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- -# Uploading agreement 'dev-MySecondAgreement' into the Azure Integration Account 'my-integration-account' # Agreement 'dev-MySecondAgreement' has been uploaded into the Azure Integration Account 'my-integration-account' -# ---------- ``` **Agreement JSON Example** diff --git a/docs/preview/03-Features/powershell/azure-key-vault.md b/docs/preview/03-Features/powershell/azure-key-vault.md index 6733bb40..262a196c 100644 --- a/docs/preview/03-Features/powershell/azure-key-vault.md +++ b/docs/preview/03-Features/powershell/azure-key-vault.md @@ -26,18 +26,16 @@ Lists the current available access policies of the Azure Key Vault resource. ```powershell PS> $accessPolicies = Get-AzKeyVaultAccessPolicies -KeyVaultName "my-key-vault" -# Looking for the Azure Key Vault with name 'my-key-vault'... -# Found Azure Key Vault 'my-key-vault' # accessPolicies: {list: [{tenantId: ...,permissions: ...}]} +# Successfully retrieved Azure Key Vault access policies ``` ```powershell PS> $accessPolicies = Get-AzKeyVaultAccessPolicies ` -KeyVaultName "my-key-vault" ` -ResourceGroupName "my-resource-group" -# Looking for the Azure Key Vault with name 'my-key-vault' in resource group 'my-resource-group'... -# Found Azure Key Vault 'my-key-vault' # accessPolicies: {list: [{tenantId: ...,permissions: ...}]} +# Successfully retrieved Azure Key Vault access policies ``` ## Setting a secret value from file into Azure Key Vault @@ -57,8 +55,7 @@ PS> Set-AzKeyVaultSecretFromFile ` -KeyVaultName "my-key-vault" ` -SecretName "my-secret" ` -FilePath "/file-path/secret-certificate.pfx" -# Creating Azure Key Vault secret from file... -# Azure Key Vault Secret 'my-secret' (Version: 'new-secret-version') has been created +# Azure Key Vault secret 'my-secret' (Version: 'new-secret-version') has been created in Azure Key vault 'my-key-vault' ``` And with expiration date: @@ -68,8 +65,7 @@ PS> Set-AzKeyVaultSecretFromFile ` -SecretName "my-secret" ` -Expires [Datetime]::ParseExact('07/15/2019', 'MM/dd/yyyy', $null) ` -KeyVaultName "my-key-vault" -# Creating Azure Key Vault secret from file... -# Azure Key Vault Secret 'my-secret' (Version: 'new-secret-version') has been created +# Azure Key Vault secret 'my-secret' (Version: 'new-secret-version') has been created in Azure Key vault 'my-key-vault' ``` ## Setting a secret value with BASE64 encoded file-content into Azure Key Vault @@ -90,9 +86,8 @@ PS> Set-AzKeyVaultSecretAsBase64FromFile ` -KeyVaultName "my-key-vault" ` -SecretName "my-secret" ` -FilePath "/file-path/secret-certificate.pfx" -# Creating Azure Key Vault secret from file... -# Use BASE64 format as secret format -# Azure Key Vault Secret 'my-secret' (Version: 'new-secret-version') has been created +# Use BASE64 format as format to create Azure Key vault secret 'my-secret' in Azure Key vault 'my-key-vault' +# Azure Key Vault secret 'my-secret' (Version: 'new-secret-version') has been created in Azure Key vault 'my-key-vault' ``` And with expiration date: @@ -102,6 +97,5 @@ PS> Set-AzKeyVaultSecretAsBase64FromFile ` -SecretName "my-secret" ` -Expires [Datetime]::ParseExact('07/15/2019', 'MM/dd/yyyy', $null) ` -KeyVaultName "my-key-vault" -# Creating Azure Key Vault secret from file... -# Azure Key Vault Secret 'my-secret' (Version: 'new-secret-version') has been created +# Azure Key Vault secret 'my-secret' (Version: 'new-secret-version') has been created in Azure Key vault 'my-key-vault' ``` diff --git a/docs/preview/03-Features/powershell/azure-logic-apps.md b/docs/preview/03-Features/powershell/azure-logic-apps.md index 6f2314d1..46414474 100644 --- a/docs/preview/03-Features/powershell/azure-logic-apps.md +++ b/docs/preview/03-Features/powershell/azure-logic-apps.md @@ -36,10 +36,7 @@ Taking an example in which a specific Azure Logic Apps (`"rcv-shopping-order-sft PS> Disable-AzLogicApp ` -ResourceGroupName "rg-common-dev" ` -LogicAppName "rcv-shopping-order-sftp" -# Access-token and subscriptionId retrieved -# Attempting to disable rcv-shopping-order-sftp - -# Successfully disabled rcv-shopping-order-sftp +# Successfully disabled Azure Logic App 'rcv-shopping-order-sftp' in resource group 'rg-common-dev' ``` Taking an example in which a specific Azure Logic Apps (`"rcv-shopping-order-sftp"`) needs to be disabled, with providing the subscriptionId or accesstoken. @@ -50,9 +47,7 @@ PS> Disable-AzLogicApp ` -ResourceGroupName "rg-common-dev" ` -LogicAppName "rcv-shopping-order-sftp" ` -AccessToken $AccessToken -# Attempting to disable rcv-shopping-order-sftp - -# Successfully disabled rcv-shopping-order-sftp +# Successfully disabled Azure Logic App 'rcv-shopping-order-sftp' in resource group 'rg-common-dev' ``` ## Enable an Azure Logic App @@ -78,10 +73,7 @@ Taking an example in which a specific Azure Logic Apps (`"rcv-shopping-order-sft PS> Enable-AzLogicApp ` -ResourceGroupName "rg-common-dev" ` -LogicAppName "rcv-shopping-order-sftp" -# Access-token and subscriptionId retrieved -# Attempting to enable rcv-shopping-order-sftp - -# Successfully enabled rcv-shopping-order-sftp +# Successfully enabled Azure Logic App 'rcv-shopping-order-sftp' in resource group 'rg-common-dev' ``` Taking an example in which a specific Azure Logic Apps (`"rcv-shopping-order-sftp"`) needs to be enabled, with providing the subscriptionId or accesstoken. @@ -92,9 +84,7 @@ PS> Enable-AzLogicApp ` -ResourceGroupName "rg-common-dev" ` -LogicAppName "rcv-shopping-order-sftp" ` -AccessToken $AccessToken -# Attempting to enable rcv-shopping-order-sftp - -# Successfully enabled rcv-shopping-order-sftp +# Successfully enabled Azure Logic App 'rcv-shopping-order-sftp' in resource group 'rg-common-dev' ``` ## Disabling Azure Logic Apps from configuration file @@ -176,47 +166,33 @@ PS> Disable-AzLogicAppsFromConfig ` -DeployFilename "./deploy-orderControl" ` -ResourceGroupName "my-resource-group" # Executing batch: Protocol Receiver(s) -# ========================== -# > Executing CheckType 'None' for batch 'Protocol Receiver(s)' in resource group 'my-resource-group'" +# Executing CheckType 'None' for batch 'Protocol Receiver(s)' in resource group 'my-resource-group'" # Executing Check 'None' => performing no check and executing stopType -# > Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' -# Attempting to disable rcv-shopping-order-ftp -# Successfully disabled rcv-shopping-order-ftp +# Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' -# > Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-sftp' in resource group 'my-resource-group' -# Attempting to disable rcv-shopping-order-sftp -# Successfully disabled rcv-shopping-order-sftp +# Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-sftp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'rcv-shopping-order-sftp' in resource group 'my-resource-group' -# > Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' -# Attempting to disable rcv-shopping-order-file -# Successfully disabled rcv-shopping-order-file - -# -> Batch: 'Protocol Receiver(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' +# Batch: 'Protocol Receiver(s)' has been executed # Executing batch: 'Generic Receiver(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'rcv-shopping-order' in resource group 'my-resource-group' -# Attempting to disable rcv-shopping-order -# Successfully disabled rcv-shopping-order - -# -> Batch: 'Generic Receiver(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'rcv-shopping-order' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'rcv-shopping-order' in resource group 'my-resource-group' +# Batch: 'Generic Receiver(s)' has been executed # Executing batch: 'Orchestrator(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' -# Attempting to disable orc-shopping-order-processing -# Successfully disabled orc-shopping-order-processing - -# -> Batch: 'Orchestrator(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' +# Batch: 'Orchestrator(s)' has been executed # Executing batch: 'Sender(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' -# Attempting to disable snd-shopping-order-confirmation-smtp -# Successfully disabled snd-shopping-order-confirmation-smtp - -# -> Batch: 'Sender(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'snd-shopping-order-smtp' in resource group 'my-resource-group' +# Batch: 'Sender(s)' has been executed ``` Disables all the Logic Apps based on the `./deploy-orderControl.json` configuration file with specifying a resource-prefix. @@ -228,47 +204,33 @@ PS> Disable-AzLogicAppsFromConfig ` -ResourceGroupName "my-resource-group" ` -ResourcePrefix "la-cod-dev-we-" # Executing batch: Protocol Receiver(s) -# ========================== -# > Executing CheckType 'None' for batch 'Protocol Receiver(s)' in resource group 'my-resource-group'" +# Executing CheckType 'None' for batch 'Protocol Receiver(s)' in resource group 'my-resource-group'" # Executing Check 'None' => performing no check and executing stopType -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-rcv-shopping-order-ftp -# Successfully disabled la-cod-dev-we-rcv-shopping-order-ftp - -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-rcv-shopping-order-sftp -# Successfully disabled la-cod-dev-we-rcv-shopping-order-sftp +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-rcv-shopping-order-file -# Successfully disabled la-cod-dev-we-rcv-shopping-order-file +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' -# -> Batch: 'Protocol Receiver(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' +# Batch: 'Protocol Receiver(s)' has been executed # Executing batch: 'Generic Receiver(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-rcv-shopping-order -# Successfully disabled la-cod-dev-we-rcv-shopping-order - -# -> Batch: 'Generic Receiver(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' +# Batch: 'Generic Receiver(s)' has been executed # Executing batch: 'Orchestrator(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-orc-shopping-order-processing -# Successfully disabled la-cod-dev-we-orc-shopping-order-processing - -# -> Batch: 'Orchestrator(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' +# Batch: 'Orchestrator(s)' has been executed # Executing batch: 'Sender(s)' -# ========================== -# > Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' -# Attempting to disable la-cod-dev-we-snd-shopping-order-confirmation-smtp -# Successfully disabled la-cod-dev-we-snd-shopping-order-confirmation-smtp - -# -> Batch: 'Sender(s)' has been executed +# Executing StopType 'Immediate' for Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Successfully disabled Azure Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Batch: 'Sender(s)' has been executed ``` ## Enabling Azure Logic Apps from configuration file @@ -350,44 +312,30 @@ PS> Enable-AzLogicAppsFromConfig ` -DeployFilename "./deploy-orderControl" ` -ResourceGroupName "my-resource-group" # Executing batch: 'Sender(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' -# Attempting to enable snd-shopping-order-confirmation-smtp -# Successfully enabled snd-shopping-order-confirmation-smtp - -# -> Batch: 'Sender(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Batch: 'Sender(s)' has been executed # Executing batch: 'Orchestrator(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' -# Attempting to enable orc-shopping-order-processing -# Successfully enabled orc-shopping-order-processing - -# -> Batch: 'Orchestrator(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'orc-shopping-order-processing' in resource group 'my-resource-group' +# Batch: 'Orchestrator(s)' has been executed # Executing batch: 'Generic Receiver(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order' in resource group 'my-resource-group' -# Attempting to enable rcv-shopping-order -# Successfully enabled rcv-shopping-order - -# -> Batch: 'Generic Receiver(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'rcv-shopping-order' in resource group 'my-resource-group' +# Batch: 'Generic Receiver(s)' has been executed # Executing batch: Protocol Receiver(s) -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' -# Attempting to enable rcv-shopping-order-ftp -# Successfully enabled rcv-shopping-order-ftp +# Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'rcv-shopping-order-ftp' in resource group 'my-resource-group' -# > Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-sftp' in resource group 'my-resource-group' -# Attempting to enable rcv-shopping-order-sftp +# Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-sftp' in resource group 'my-resource-group' # Successfully enabled rcv-shopping-order-sftp -# > Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' -# Attempting to enable rcv-shopping-order-file -# Successfully enabled rcv-shopping-order-file - -# -> Batch: 'Protocol Receiver(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'rcv-shopping-order-file' in resource group 'my-resource-group' +# Batch: 'Protocol Receiver(s)' has been executed ``` Enables all the Logic Apps based on the `./deploy-orderControl.json` configuration file with specifying a resource-prefix. @@ -399,42 +347,28 @@ PS> Enable-AzLogicAppsFromConfig ` -ResourceGroupName "my-resource-group" ` -ResourcePrefix "la-cod-dev-we-" # Executing batch: 'Sender(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-snd-shopping-order-confirmation-smtp -# Successfully enabled la-cod-dev-we-snd-shopping-order-confirmation-smtp - -# -> Batch: 'Sender(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-snd-shopping-order-confirmation-smtp' in resource group 'my-resource-group' +# Batch: 'Sender(s)' has been executed # Executing batch: 'Orchestrator(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-orc-shopping-order-processing -# Successfully enabled la-cod-dev-we-orc-shopping-order-processing - -# -> Batch: 'Orchestrator(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-orc-shopping-order-processing' in resource group 'my-resource-group' +# Batch: 'Orchestrator(s)' has been executed # Executing batch: 'Generic Receiver(s)' -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-rcv-shopping-order -# Successfully enabled la-cod-dev-we-rcv-shopping-order - -# -> Batch: 'Generic Receiver(s)' has been executed +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order' in resource group 'my-resource-group' +# Batch: 'Generic Receiver(s)' has been executed # Executing batch: Protocol Receiver(s) -# ========================== -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-rcv-shopping-order-ftp -# Successfully enabled la-cod-dev-we-rcv-shopping-order-ftp +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-ftp' in resource group 'my-resource-group' -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-rcv-shopping-order-sftp -# Successfully enabled la-cod-dev-we-rcv-shopping-order-sftp +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-sftp' in resource group 'my-resource-group' -# > Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' -# Attempting to enable la-cod-dev-we-rcv-shopping-order-file -# Successfully enabled la-cod-dev-we-rcv-shopping-order-file - -# -> Batch: 'Protocol Receiver(s)' has been executed -``` +# Reverting StopType 'Immediate' for Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' +# Successfully enabled Azure Logic App 'la-cod-dev-we-rcv-shopping-order-file' in resource group 'my-resource-group' +# Batch: 'Protocol Receiver(s)' has been executed +``` \ No newline at end of file diff --git a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 index 3a1478ec..418b6ab0 100644 --- a/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 +++ b/src/Arcus.Scripting.ApiManagement/Scripts/Create-AzApiManagementApiOperation.ps1 @@ -17,7 +17,7 @@ if ($apim -eq $null) { $apimContext = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName New-AzApiManagementOperation -Context $apimContext -ApiId $ApiId -OperationId $OperationId -Name $OperationName -Method $Method -UrlTemplate $UrlTemplate -Description $Description -Write-Host "New API operation '$OperationName' was added on Azure API Management service '$($ServiceName)' in resource group '$($ResourceGroupName)'" +Write-Host "New API operation '$OperationName' was added on Azure API Management service '$ServiceName' in resource group '$ResourceGroupName'" if($OperationId -eq "" -or $PolicyFilePath -eq "") { diff --git a/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 b/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 index 5f65df47..4e84a9e3 100644 --- a/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 +++ b/src/Arcus.Scripting.DataFactory/Scripts/Set-AzDataFactoryTriggerState.ps1 @@ -1,67 +1,48 @@ param( - [Parameter(Mandatory=$true)][string]$Action = $(throw "Action is required [Start|Stop]"), - [Parameter(Mandatory=$true)][string]$ResourceGroupName = $(throw "ResourceGroup is required"), - [Parameter(Mandatory=$true)][string]$DataFactoryName = $(throw "The name of the data factory is required"), - [Parameter(Mandatory=$true)][string]$DataFactoryTriggerName = $(throw "The name of the trigger is required"), - [Parameter(Mandatory=$false)][switch]$FailWhenTriggerIsNotFound = $false + [Parameter(Mandatory=$true)][string] $Action = $(throw "Action is required [Start|Stop]"), + [Parameter(Mandatory=$true)][string] $ResourceGroupName = $(throw "ResourceGroup is required"), + [Parameter(Mandatory=$true)][string] $DataFactoryName = $(throw "The name of the data factory is required"), + [Parameter(Mandatory=$true)][string] $DataFactoryTriggerName = $(throw "The name of the trigger is required"), + [Parameter(Mandatory=$false)][switch] $FailWhenTriggerIsNotFound = $false ) -try -{ +try { $dataFactory = Get-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName -Name $DataFactoryName -ErrorAction Stop -} -catch -{ +} catch { throw "Error finding data factory '$DataFactoryName' in resource group '$ResourceGroupName'" } -try -{ +try { $DataFactoryTrigger = Get-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataFactoryTriggerName -ErrorAction Stop -} -catch -{ +} catch { $message = "Error retrieving trigger '$DataFactoryTriggerName' in data factory '$DataFactoryName'" - if($FailWhenTriggerIsNotFound) - { + if ($FailWhenTriggerIsNotFound) { throw $message - } - else - { + } else { Write-Warning $message Write-verbose "Skipping the '$Action'-operation." return } } -if($Action -eq "Start") -{ - try - { - if($null -ne $DataFactoryTrigger) - { +if ($Action -eq "Start") { + try { + if ($null -ne $DataFactoryTrigger) { $succeeded = Start-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataFactoryTriggerName -Force -ErrorAction Stop Write-Host "Started Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" -ForegroundColor Green } - } - catch - { + } catch { throw "Error starting Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" } } -if($Action -eq "Stop") -{ - try - { - if($null -ne $DataFactoryTrigger) - { +if ($Action -eq "Stop") { + try { + if ($null -ne $DataFactoryTrigger) { $succeeded = Stop-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName -DataFactoryName $DataFactoryName -Name $DataFactoryTriggerName -Force -ErrorAction Stop Write-Host "Stopped Azure Data Factory trigger '$DataFactoryTriggerName' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" -ForegroundColor Green } - } - catch - { + } catch { throw "Error stopping Azure Data Factory trigger '$DataFactoryTrigger' of data factory '$DataFactoryName' in resource group '$ResourceGroupName'" } } \ No newline at end of file diff --git a/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 b/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 index 58ce454b..b5ba3524 100644 --- a/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 +++ b/src/Arcus.Scripting.KeyVault/Scripts/Set-AzKeyVaultSecretFromFile.ps1 @@ -12,11 +12,11 @@ if ($false -eq $isFileFound) { throw "Cannot set an Azure Key Vault secret because no file containing the secret certificate was found" } -Write-Verbose "Creating Azure Key Vault secret from file..." +Write-Verbose "Creating Azure Key Vault secret '$SecretName' from file in Azure Key vault '$KeyVaultName'..." $secretValue = $null if ($Base64) { - Write-Verbose "Use BASE64 format as secret format" + Write-Verbose "Use BASE64 format as format to create Azure Key vault secret '$SecretName' in Azure Key vault '$KeyVaultName'" $content = Get-Content $filePath -Raw $bytes = [System.Text.Encoding]::UTF8.GetBytes($content) $contentBase64 = [System.Convert]::ToBase64String($bytes) @@ -34,4 +34,4 @@ if ($Expires -ne $null) { } $version = $secret.Version -Write-Host "Azure Key Vault Secret '$SecretName' (Version: '$version') has been created" -ForegroundColor Green +Write-Host "Azure Key Vault secret '$SecretName' (Version: '$version') has been created in Azure Key vault '$KeyVaultName'" -ForegroundColor Green diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 index cdd45a50..e9e2f337 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Disable-AzLogicApp.ps1 @@ -18,7 +18,7 @@ try{ $fullUrl = . $PSScriptRoot\Get-AzLogicAppResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $SubscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -ApiVersion $ApiVersion -Action "disable" - Write-Verbose "Attempting to disable Azure Logic App '$LogicAppName'..." + Write-Verbose "Attempting to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'..." $params = @{ Method = 'Post' Headers = @{ @@ -28,10 +28,10 @@ try{ } $web = Invoke-WebRequest @params -ErrorAction Stop - Write-Host "Successfully disabled Azure Logic App '$LogicAppName'" -ForegroundColor Green + Write-Host "Successfully disabled Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green } catch { - Write-Warning "Failed to disable Azure Logic App '$LogicAppName'" + Write-Warning "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" $ErrorMessage = $_.Exception.Message Write-Debug "Error: $ErrorMessage" } \ No newline at end of file diff --git a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 index af8db433..17c1ff4c 100644 --- a/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 +++ b/src/Arcus.Scripting.LogicApps/Scripts/Enable-AzLogicAppsFromConfig.ps1 @@ -32,7 +32,7 @@ function ReverseStopType() { Write-Warning "Failed to enable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" $ErrorMessage = $_.Exception.Message Write-Debug "Error: $ErrorMessage" - } + } } } else { From e33076bedd4f650b6faa803a7ef3f8d6390942f6 Mon Sep 17 00:00:00 2001 From: stijnmoreels <9039753+stijnmoreels@users.noreply.github.com> Date: Tue, 27 Dec 2022 08:00:04 +0100 Subject: [PATCH 10/10] pr-fix: update w/ correct failure message --- .../Arcus.Scripting.LogicApps.tests.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 index c852ce6d..9a4e36ec 100644 --- a/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 +++ b/src/Arcus.Scripting.Tests.Unit/Arcus.Scripting.LogicApps.tests.ps1 @@ -91,7 +91,7 @@ InModuleScope Arcus.Scripting.LogicApps { $response | Add-Member -MemberType noteProperty -Name 'StatusCode' -Value 404 -force $exception = New-Object System.Net.WebException $errorContent , $null, $status, $response - Throw $exception + throw $exception } Mock Get-AzCachedAccessToken -MockWith { return @{ @@ -107,7 +107,7 @@ InModuleScope Arcus.Scripting.LogicApps { # Assert Assert-VerifiableMock Assert-MockCalled Get-AzCachedAccessToken -Scope It -Times 1 - Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -contains "Failed to disable Azure Logic App '$LogicAppName'" } + Assert-MockCalled Write-Warning -Scope It -Times 1 -ParameterFilter { $Message -eq "Failed to disable Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" } Assert-MockCalled Write-Debug -Scope It -Times 1 -ParameterFilter { $Message -eq "Error: $errorContent" } } }