@@ -2484,6 +2484,152 @@ Task -Name "Set-Arm.Connections.ManagedApis.SftpWithSsh.Username.Advanced.AsArmO
24842484 Out-TaskFileArm - InputObject $armObj
24852485}
24862486
2487+ # Original file: Set-Arm.Connections.ManagedApis.Smtp.Username.AsArmObject.task.ps1
2488+ $parm = @ {
2489+ Description = @"
2490+ Loops all `$ connections children
2491+ -Validates that is of the type smtp
2492+ --Creates a new resource in the ARM template, for the ApiConnection object
2493+ --With matching ARM Parameters, for the Hostname, Username, Password, Port, Ssl
2494+ --Makes sure the ARM Parameters logicAppLocation exists
2495+ --Name & Displayname is extracted from the Api Connection Object
2496+ Requires an authenticated session, either Az.Accounts or az cli
2497+ "@
2498+ Alias = " Arm.Set-Arm.Connections.ManagedApis.Smtp.Username.AsArmObject"
2499+ }
2500+
2501+ Task - Name " Set-Arm.Connections.ManagedApis.Smtp.Username.AsArmObject" @parm - Action {
2502+ Set-TaskWorkDirectory
2503+
2504+ # We can either use the az cli or the Az modules
2505+ $tools = Get-PSFConfigValue - FullName PsLogicAppExtractor.Execution.Tools
2506+
2507+ $found = $false
2508+
2509+ $armObj = Get-TaskWorkObject
2510+
2511+ $armObj.resources [0 ].properties.parameters.' $connections' .value.PsObject.Properties | ForEach-Object {
2512+
2513+ if ($_.Value.id -like " *managedApis/smtp*" ) {
2514+ $found = $true
2515+
2516+ # Fetch the details from the connection object
2517+ $uri = " {0}?api-version=2018-07-01-preview" -f $ ($_.Value.connectionId )
2518+
2519+ if ($tools -eq " AzCli" ) {
2520+ $resObj = az rest -- url $uri | ConvertFrom-Json
2521+ }
2522+ else {
2523+ $resObj = Invoke-AzRestMethod - Path $uri - Method Get | Select-Object - ExpandProperty content | ConvertFrom-Json
2524+ }
2525+
2526+ # Use the display name as the name of the resource
2527+ $conName = $resObj.Properties.DisplayName
2528+ $displayName = $resObj.Properties.DisplayName
2529+ $hostName = $resObj.Properties.ParameterValues.serverAddress
2530+ $userName = $resObj.Properties.ParameterValues.userName
2531+ $portNumber = $resObj.Properties.ParameterValues.port
2532+ $enableSsl = $resObj.Properties.ParameterValues.enableSSL
2533+
2534+ if ([string ]::IsNullOrEmpty($portNumber )) {
2535+ $portNumber = 587
2536+ }
2537+
2538+ # Fetch base template
2539+ $pathArms = " $ ( Get-PSFConfigValue - FullName PsLogicAppExtractor.ModulePath.Base) \internal\arms"
2540+ $apiObj = Get-Content - Path " $pathArms \API.Smtp.json" - Raw | ConvertFrom-Json
2541+
2542+ # Set the names of the parameters
2543+ $Prefix = Get-PSFConfigValue - FullName PsLogicAppExtractor.prefixsuffix.connection.prefix
2544+ $hostPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _Hostname" - Value " $ ( $_.Name ) "
2545+ $userPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _Username" - Value " $ ( $_.Name ) "
2546+ $passPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _Password" - Value " $ ( $_.Name ) "
2547+ $portPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _Port" - Value " $ ( $_.Name ) "
2548+ $sslPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _EnableSsl" - Value " $ ( $_.Name ) "
2549+
2550+ $idPreSuf = Format-Name - Type " Connection" - Value " $ ( $_.Name ) "
2551+ $displayPreSuf = Format-Name - Type " Connection" - Prefix $Prefix - Suffix " _DisplayName" - Value " $ ( $_.Name ) "
2552+
2553+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $hostPreSuf " `
2554+ - Type " string" `
2555+ - Value " $hostName " `
2556+ - Description " The host / server address for the Smtp server. ($ ( $_.Name ) )"
2557+
2558+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $userPreSuf " `
2559+ - Type " string" `
2560+ - Value " $userName " `
2561+ - Description " The username used to authenticate against the Smtp server. ($ ( $_.Name ) )"
2562+
2563+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $passPreSuf " `
2564+ - Type " SecureString" `
2565+ - Value " " `
2566+ - Description " The password used to authenticate against the Smtp server. ($ ( $_.Name ) )"
2567+
2568+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $portPreSuf " `
2569+ - Type " string" `
2570+ - Value " $portNumber " `
2571+ - Description " The port used to communicate with the Smtp server. ($ ( $_.Name ) )"
2572+
2573+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $sslPreSuf " `
2574+ - Type " bool" `
2575+ - Value $enableSsl `
2576+ - Description " Indicate if you need SSL turned on to authenticate against the Smtp server. ($ ( $_.Name ) )"
2577+
2578+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $displayPreSuf " `
2579+ - Type " string" `
2580+ - Value $displayName `
2581+ - Description " The display name of the ManagedApi connection object that is being utilized by the Logic App."
2582+
2583+ $armObj = Add-ArmParameter - InputObject $armObj - Name " $idPreSuf " `
2584+ - Type " string" `
2585+ - Value $conName `
2586+ - 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."
2587+
2588+ # Update the api object properties
2589+ $apiObj.Name = " [parameters('$idPreSuf ')]"
2590+ $apiObj.properties.displayName = " [parameters('$displayPreSuf ')]"
2591+ $apiObj.Properties.ParameterValues.serverAddress = " [parameters('$hostPreSuf ')]"
2592+ $apiObj.Properties.ParameterValues.userName = " [parameters('$userPreSuf ')]"
2593+ $apiObj.Properties.ParameterValues.password = " [parameters('$passPreSuf ')]"
2594+ $apiObj.Properties.ParameterValues.port = " [parameters('$portPreSuf ')]"
2595+ $apiObj.Properties.ParameterValues.enableSSL = " [parameters('$sslPreSuf ')]"
2596+
2597+ # Update the api connection object type
2598+ $_.Value.id -match " /managedApis/(.*)"
2599+ $conType = $Matches [1 ]
2600+ $apiObj.properties.api.id = $apiObj.properties.api.id.Replace (" ##TYPE##" , $conType )
2601+
2602+ # Append the new resource to the ARM template
2603+ $armObj.resources += $apiObj
2604+
2605+ if ($null -eq $armObj.resources [0 ].dependsOn) {
2606+ # Create the dependsOn array if it does not exist
2607+ $armObj.resources [0 ] | Add-Member - MemberType NoteProperty - Name " dependsOn" - Value @ ()
2608+ }
2609+
2610+ # Add the new resource to the dependsOn array, so that the deployment will work
2611+ $armObj.resources [0 ].dependsOn += " [resourceId('Microsoft.Web/connections', parameters('$idPreSuf '))]"
2612+
2613+ # Adjust the connection object to depend on the same name
2614+ $_.Value.connectionId = " [resourceId('Microsoft.Web/connections', parameters('$idPreSuf '))]"
2615+ $_.Value.connectionName = " [parameters('$idPreSuf ')]"
2616+ $_.Value.id = " [format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/$conType ', subscription().subscriptionId, parameters('logicAppLocation'))]"
2617+ }
2618+ }
2619+
2620+ if ($found ) {
2621+ # We need the location parameter
2622+ if ($null -eq $armObj.parameters.logicAppLocation ) {
2623+ $armObj = Add-ArmParameter - InputObject $armObj - Name " logicAppLocation" `
2624+ - Type " string" `
2625+ - Value " [resourceGroup().location]" `
2626+ - Description " Location of the Logic App. Best practice recommendation is to make this depending on the Resource Group and its location."
2627+ }
2628+ }
2629+
2630+ Out-TaskFileArm - InputObject $armObj
2631+ }
2632+
24872633# Original file: Set-Arm.Connections.ManagedApis.Storage.BlobOrFile.ListKey.Advanced.AsArmObject.task.ps1
24882634$parm = @ {
24892635 Description = @"
0 commit comments