@@ -3000,6 +3000,123 @@ Task -Name "Set-Arm.Connections.ManagedApis.Storage.Table.ListKey.Advanced.AsArm
30003000 Out-TaskFileArm - InputObject $armObj
30013001}
30023002
3003+ # Original file: Set-Arm.Connections.ManagedApis.VisualStudioTeamServices.ServicePrincipal.Advanced.AsArmObject.task.ps1
3004+ $parm = @ {
3005+ Description = @"
3006+ Loops all `$ connections children
3007+ -Validates that is of the type Azure DevOps / Visual Studio Team Services
3008+ --Creates a new resource in the ARM template, for the ApiConnection object
3009+ --With matching ARM Parameters, for the Namespace
3010+ --Makes sure the ARM Parameters logicAppLocation exists
3011+ --The type is based on the Service Principal authentication
3012+ --Name & Display Name is extracted from the connection object
3013+ Requires an authenticated session, either Az.Accounts or az cli
3014+ "@
3015+ Alias = " Arm.Set-Arm.Connections.ManagedApis.VisualStudioTeamServices.ServicePrincipal.Advanced.AsArmObject"
3016+ }
3017+
3018+ Task - Name " Set-Arm.Connections.ManagedApis.VisualStudioTeamServices.ServicePrincipal.Advanced.AsArmObject" @parm - Action {
3019+ Set-TaskWorkDirectory
3020+
3021+ # We can either use the az cli or the Az modules
3022+ $tools = Get-PSFConfigValue - FullName PsLogicAppExtractor.Execution.Tools
3023+
3024+ $found = $false
3025+ $conType = " visualstudioteamservices"
3026+
3027+ $armObj = Get-TaskWorkObject
3028+
3029+ foreach ($connectionObj in $armObj.resources [0 ].properties.parameters.' $connections' .value.PsObject.Properties) {
3030+ if ($connectionObj.Value.id -like " *managedApis/visualstudioteamservices*" ) {
3031+ $found = $true
3032+
3033+ # Fetch the details from the connection object
3034+ $uri = " {0}?api-version=2018-07-01-preview" -f $ ($connectionObj.Value.connectionId )
3035+
3036+ if ($tools -eq " AzCli" ) {
3037+ $resObj = az rest -- url $uri | ConvertFrom-Json
3038+ }
3039+ else {
3040+ $resObj = Invoke-AzRestMethod - Path $uri - Method Get | Select-Object - ExpandProperty content | ConvertFrom-Json
3041+ }
3042+
3043+ # Use the display name as the name of the resource
3044+ $conName = $resObj.Properties.DisplayName
3045+
3046+ $tenantId = $resObj.properties.parameterValueSet.values ." token:TenantId" .value
3047+ $clientId = $resObj.properties.parameterValueSet.values ." token:clientId" .value
3048+
3049+ # Fetch base template
3050+ $pathArms = " $ ( Get-PSFConfigValue - FullName PsLogicAppExtractor.ModulePath.Base) \internal\arms"
3051+ $apiObj = Get-Content - Path " $pathArms \API.AzureDevOps.ServicePrincipal.json" - Raw | ConvertFrom-Json
3052+
3053+ # Set the names of the parameters
3054+ $Prefix = Get-PSFConfigValue - FullName PsLogicAppExtractor.prefixsuffix.connection.prefix
3055+ $parmApicId = Format-Name - Type " Connection" - Prefix $Prefix - Value " $ ( $connectionObj.Name ) "
3056+ $parmApicTenant = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _TenantId" - Value " $ ( $connectionObj.Name ) "
3057+ $parmApicClient = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _ClientId" - Value " $ ( $connectionObj.Name ) "
3058+ $parmApicSecret = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _ClientSecret" - Value " $ ( $connectionObj.Name ) "
3059+
3060+ # $idPreSuf = Format-Name -Type "Connection" -Value "$($_.Name)"
3061+ # $displayPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_DisplayName" -Value "$($_.Name)"
3062+
3063+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $parmApicId " `
3064+ - Type " string" `
3065+ - Value $conName `
3066+ - Description " The name / id of the ManagedApi connection object that is being utilized by the Logic App. Will be for the trigger and other actions that depend on connections."
3067+
3068+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $parmApicTenant " `
3069+ - Type " string" `
3070+ - Value " $tenantId " `
3071+ - Description " The Azure tenant id that the Azure DevOps instance is connected to. ($ ( $_.Name ) )"
3072+
3073+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $parmApicClient " `
3074+ - Type " string" `
3075+ - Value " $clientId " `
3076+ - Description " The ClientId used to authenticate against the Azure DevOps instance. ($ ( $_.Name ) )"
3077+
3078+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $parmApicSecret " `
3079+ - Type " SecureString" `
3080+ - Value " " `
3081+ - Description " The ClientSecret used to authenticate against the Azure DevOps instance. ($ ( $_.Name ) )"
3082+
3083+ # Update the api object properties
3084+ $apiObj.Name = " [parameters('$parmApicId ')]"
3085+ $apiObj.properties.displayName = " [parameters('$parmApicId ')]"
3086+ $apiObj.properties.parameterValueSet.values ." token:TenantId" .value = " [parameters('$parmApicTenant ')]"
3087+ $apiObj.properties.parameterValueSet.values ." token:clientId" .value = " [parameters('$parmApicClient ')]"
3088+ $apiObj.properties.parameterValueSet.values ." token:clientSecret" .value = " [parameters('$parmApicSecret ')]"
3089+
3090+ # Append the new resource to the ARM template
3091+ $armObj.resources += $apiObj
3092+
3093+ if ($null -eq $armObj.resources [0 ].dependsOn) {
3094+ # Create the dependsOn array if it does not exist
3095+ $armObj.resources [0 ] | Add-Member - MemberType NoteProperty - Name " dependsOn" - Value @ ()
3096+ }
3097+
3098+ # Add the new resource to the dependsOn array, so that the deployment will work
3099+ $armObj.resources [0 ].dependsOn += " [resourceId('Microsoft.Web/connections', parameters('$parmApicId '))]"
3100+
3101+ # Adjust the connection object to depend on the same name
3102+ $connectionObj.Value.connectionId = " [resourceId('Microsoft.Web/connections', parameters('$parmApicId '))]"
3103+ $connectionObj.Value.connectionName = " [parameters('$parmApicId ')]"
3104+ $connectionObj.Value.id = " [format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/$conType ', subscription().subscriptionId, parameters('logicAppLocation'))]"
3105+ }
3106+ }
3107+
3108+ if ($found ) {
3109+ if ($null -eq $armObj.parameters.logicAppLocation ) {
3110+ $armObj = Add-ArmParameter - InputObject $armObj - Name " logicAppLocation" `
3111+ - Type " string" `
3112+ - Value " [resourceGroup().location]" `
3113+ - Description " Location of the Logic App. Best practice recommendation is to make this depending on the Resource Group and its location."
3114+ }
3115+ }
3116+
3117+ Out-TaskFileArm - InputObject $armObj
3118+ }
3119+
30033120# Original file: Set-Arm.Diagnostics.Settings.Workspace.Advanced.AsArmObject.task.ps1
30043121$parm = @ {
30053122 Description = @"
0 commit comments