Skip to content

Commit ceac2df

Browse files
authored
Merge pull request #90 from LogicAppCollaborative/development
New release
2 parents ab75851 + 60a6ad9 commit ceac2df

File tree

3 files changed

+311
-0
lines changed

3 files changed

+311
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"type": "Microsoft.Web/connections",
3+
"apiVersion": "2018-07-01-preview",
4+
"name": "##NAME##",
5+
"location": "[parameters('logicAppLocation')]",
6+
"kind": "V1",
7+
"properties": {
8+
"parameterValues": {
9+
"serverAddress": "##HOSTNAME##",
10+
"userName": "##USERNAME#",
11+
"password": "##PASSWORD##",
12+
"port": "##PORTNUMBER##",
13+
"enableSSL": "##ENABLESSL##"
14+
},
15+
"displayName": "##NAME##",
16+
"customParameterValues": {},
17+
"api": {
18+
"id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicAppLocation'), '##TYPE##')]"
19+
}
20+
}
21+
}

PsLogicAppExtractor/internal/tasks/All/All.task.ps1

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = @"
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
$parm = @{
2+
Description = @"
3+
Loops all `$connections children
4+
-Validates that is of the type smtp
5+
--Creates a new resource in the ARM template, for the ApiConnection object
6+
--With matching ARM Parameters, for the Hostname, Username, Password, Port, Ssl
7+
--Makes sure the ARM Parameters logicAppLocation exists
8+
--Name & Displayname is extracted from the Api Connection Object
9+
Requires an authenticated session, either Az.Accounts or az cli
10+
"@
11+
Alias = "Arm.Set-Arm.Connections.ManagedApis.Smtp.Username.AsArmObject"
12+
}
13+
14+
Task -Name "Set-Arm.Connections.ManagedApis.Smtp.Username.AsArmObject" @parm -Action {
15+
Set-TaskWorkDirectory
16+
17+
# We can either use the az cli or the Az modules
18+
$tools = Get-PSFConfigValue -FullName PsLogicAppExtractor.Execution.Tools
19+
20+
$found = $false
21+
22+
$armObj = Get-TaskWorkObject
23+
24+
$armObj.resources[0].properties.parameters.'$connections'.value.PsObject.Properties | ForEach-Object {
25+
26+
if ($_.Value.id -like "*managedApis/smtp*") {
27+
$found = $true
28+
29+
# Fetch the details from the connection object
30+
$uri = "{0}?api-version=2018-07-01-preview" -f $($_.Value.connectionId)
31+
32+
if ($tools -eq "AzCli") {
33+
$resObj = az rest --url $uri | ConvertFrom-Json
34+
}
35+
else {
36+
$resObj = Invoke-AzRestMethod -Path $uri -Method Get | Select-Object -ExpandProperty content | ConvertFrom-Json
37+
}
38+
39+
# Use the display name as the name of the resource
40+
$conName = $resObj.Properties.DisplayName
41+
$displayName = $resObj.Properties.DisplayName
42+
$hostName = $resObj.Properties.ParameterValues.serverAddress
43+
$userName = $resObj.Properties.ParameterValues.userName
44+
$portNumber = $resObj.Properties.ParameterValues.port
45+
$enableSsl = $resObj.Properties.ParameterValues.enableSSL
46+
47+
if ([string]::IsNullOrEmpty($portNumber)) {
48+
$portNumber = 587
49+
}
50+
51+
# Fetch base template
52+
$pathArms = "$(Get-PSFConfigValue -FullName PsLogicAppExtractor.ModulePath.Base)\internal\arms"
53+
$apiObj = Get-Content -Path "$pathArms\API.Smtp.json" -Raw | ConvertFrom-Json
54+
55+
# Set the names of the parameters
56+
$Prefix = Get-PSFConfigValue -FullName PsLogicAppExtractor.prefixsuffix.connection.prefix
57+
$hostPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Hostname" -Value "$($_.Name)"
58+
$userPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Username" -Value "$($_.Name)"
59+
$passPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Password" -Value "$($_.Name)"
60+
$portPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_Port" -Value "$($_.Name)"
61+
$sslPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_EnableSsl" -Value "$($_.Name)"
62+
63+
$idPreSuf = Format-Name -Type "Connection" -Value "$($_.Name)"
64+
$displayPreSuf = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_DisplayName" -Value "$($_.Name)"
65+
66+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$hostPreSuf" `
67+
-Type "string" `
68+
-Value "$hostName" `
69+
-Description "The host / server address for the Smtp server. ($($_.Name))"
70+
71+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$userPreSuf" `
72+
-Type "string" `
73+
-Value "$userName" `
74+
-Description "The username used to authenticate against the Smtp server. ($($_.Name))"
75+
76+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$passPreSuf" `
77+
-Type "SecureString" `
78+
-Value "" `
79+
-Description "The password used to authenticate against the Smtp server. ($($_.Name))"
80+
81+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$portPreSuf" `
82+
-Type "string" `
83+
-Value "$portNumber" `
84+
-Description "The port used to communicate with the Smtp server. ($($_.Name))"
85+
86+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$sslPreSuf" `
87+
-Type "bool" `
88+
-Value $enableSsl `
89+
-Description "Indicate if you need SSL turned on to authenticate against the Smtp server. ($($_.Name))"
90+
91+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$displayPreSuf" `
92+
-Type "string" `
93+
-Value $displayName `
94+
-Description "The display name of the ManagedApi connection object that is being utilized by the Logic App."
95+
96+
$armObj = Add-ArmParameter -InputObject $armObj -Name "$idPreSuf" `
97+
-Type "string" `
98+
-Value $conName `
99+
-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."
100+
101+
# Update the api object properties
102+
$apiObj.Name = "[parameters('$idPreSuf')]"
103+
$apiObj.properties.displayName = "[parameters('$displayPreSuf')]"
104+
$apiObj.Properties.ParameterValues.serverAddress = "[parameters('$hostPreSuf')]"
105+
$apiObj.Properties.ParameterValues.userName = "[parameters('$userPreSuf')]"
106+
$apiObj.Properties.ParameterValues.password = "[parameters('$passPreSuf')]"
107+
$apiObj.Properties.ParameterValues.port = "[parameters('$portPreSuf')]"
108+
$apiObj.Properties.ParameterValues.enableSSL = "[parameters('$sslPreSuf')]"
109+
110+
# Update the api connection object type
111+
$_.Value.id -match "/managedApis/(.*)"
112+
$conType = $Matches[1]
113+
$apiObj.properties.api.id = $apiObj.properties.api.id.Replace("##TYPE##", $conType)
114+
115+
# Append the new resource to the ARM template
116+
$armObj.resources += $apiObj
117+
118+
if ($null -eq $armObj.resources[0].dependsOn) {
119+
# Create the dependsOn array if it does not exist
120+
$armObj.resources[0] | Add-Member -MemberType NoteProperty -Name "dependsOn" -Value @()
121+
}
122+
123+
# Add the new resource to the dependsOn array, so that the deployment will work
124+
$armObj.resources[0].dependsOn += "[resourceId('Microsoft.Web/connections', parameters('$idPreSuf'))]"
125+
126+
# Adjust the connection object to depend on the same name
127+
$_.Value.connectionId = "[resourceId('Microsoft.Web/connections', parameters('$idPreSuf'))]"
128+
$_.Value.connectionName = "[parameters('$idPreSuf')]"
129+
$_.Value.id = "[format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/$conType', subscription().subscriptionId, parameters('logicAppLocation'))]"
130+
}
131+
}
132+
133+
if ($found) {
134+
# We need the location parameter
135+
if ($null -eq $armObj.parameters.logicAppLocation) {
136+
$armObj = Add-ArmParameter -InputObject $armObj -Name "logicAppLocation" `
137+
-Type "string" `
138+
-Value "[resourceGroup().location]" `
139+
-Description "Location of the Logic App. Best practice recommendation is to make this depending on the Resource Group and its location."
140+
}
141+
}
142+
143+
Out-TaskFileArm -InputObject $armObj
144+
}

0 commit comments

Comments
 (0)