Skip to content

Commit 99f0bbb

Browse files
committed
Incorporating feedback from edit review
1 parent 6c282e3 commit 99f0bbb

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

articles/azure-functions/functions-hybrid-powershell.md

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ ms.author: eamono
1616
The Azure App Service Hybrid Connections enables access to resources in other networks. You can learn more about this capability on the [Hybrid Connections](../app-service/app-service-hybrid-connections.md) documentation. The following information describes how to use this capability to run PowerShell functions targeting an on-premises server. This server can then be used to manage all resources within the on-premises environment from an Azure PowerShell function.
1717

1818

19-
## Configure an on-premises server to be used for PowerShell remoting
19+
## Configure an on-premises server for PowerShell remoting
2020

2121
The below script enables PowerShell remoting, creates a new firewall rule, and a WinRM https listener. For testing purposes, a self-signed cert is used. It is recommended to use a signed certificate for production.
2222

2323
```powershell
2424
# For configuration of WinRM, please see
25-
# https://docs.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management
25+
# https://docs.microsoft.com/windows/win32/winrm/installation-and-configuration-for-windows-remote-management
2626
2727
# Enable PowerShell remoting
2828
Enable-PSRemoting -Force
@@ -79,7 +79,7 @@ App Service Hybrid Connections are only available in Basic, Standard, and Isolat
7979

8080
1. Select **Go to resource** to view your new function app. You can also select **Pin to dashboard**. Pinning makes it easier to return to this function app resource from your dashboard.
8181

82-
## Create a hybrid connection for the PowerShell function app
82+
## Create a hybrid connection for the function app
8383

8484
Hybrid connections are configured from the networking section of the function app.
8585

@@ -92,21 +92,21 @@ Hybrid connections are configured from the networking section of the function ap
9292
1. Enter information about for the hybrid connection as shown below. The Endpoint Host can optionally match the hostname of the on-premises server to make it easier to remember the server later when running remote commands. The port matches the default Windows remote management service port defined on the server earlier.
9393
![Add Hybrid Connection](./media/functions-hybrid-powershell/add-hybrid-connection.png)
9494

95-
**Hybrid connection name** ContosoHybridOnPremisesServer
95+
**Hybrid connection name** ContosoHybridOnPremisesServer
96+
97+
**Endpoint Host** finance1
98+
99+
**Endpoint Port** 5986
100+
101+
**Servicebus namespace** Create New
102+
103+
**Location** Pick an available location
104+
105+
**Name** contosopowershellhybrid
96106

97-
**Endpoint Host** finance1
107+
5. Click OK to create the hybrid connection
98108

99-
**Endpoint Port** 5986
100-
101-
**Servicebus namespace** Create New
102-
103-
**Location** Pick an available location
104-
105-
**Name** contosopowershellhybrid
106-
107-
Click OK to create the hybrid connection
108-
109-
## Download and install the hybrid connection on the on-premises server
109+
## Download and install the hybrid connection
110110

111111
1. Select the Download connection manager icon to save the .msi file locally on your computer.
112112
![Download installer](./media/functions-hybrid-powershell/download-hybrid-connection-installer.png)
@@ -124,7 +124,7 @@ Click OK to create the hybrid connection
124124
Restart-Service HybridConnectionManager
125125
```
126126

127-
## Create an app setting for the password of an account that is an administrator on the on-premises server
127+
## Create an app setting for the password of an administrator account
128128

129129
1. Select the Platform tab from the function application
130130
1. Select the Configuration from the General Settings section
@@ -134,49 +134,49 @@ Restart-Service HybridConnectionManager
134134
1. Select OK and then Save to store the password in the function application
135135
![Add app setting for password](./media/functions-hybrid-powershell/add-appsetting-password.png)
136136

137-
## Create a function http trigger to test out the hybrid connection
137+
## Create a function http trigger to test
138138

139139
1. Create a new http trigger function from the function app
140140
![Create new http trigger](./media/functions-hybrid-powershell/create-http-trigger-function.png)
141141
1. Replace the PowerShell code from the template with the following code:
142142

143-
```powershell
144-
# Input bindings are passed in via param block.
145-
param($Request, $TriggerMetadata)
146-
147-
# Write to the Azure Functions log stream.
148-
Write-Output "PowerShell HTTP trigger function processed a request."
149-
150-
# Note that ContosoUserPassword is a function app setting, so I can access it as $env:ContosoUserPassword
151-
$UserName = "ContosoUser"
152-
$securedPassword = ConvertTo-SecureString $Env:ContosoUserPassword -AsPlainText -Force
153-
$Credential = [System.management.automation.pscredential]::new($UserName, $SecuredPassword)
154-
155-
# This is the name of the hybrid connection Endpoint.
156-
$HybridEndpoint = "finance1"
157-
158-
$Script = {
159-
Param(
160-
[Parameter(Mandatory=$True)]
161-
[String] $Service
162-
)
163-
Get-Service $Service
164-
}
165-
166-
Write-Output "Scenario 1: Running command via Invoke-Command"
167-
Invoke-Command -ComputerName $HybridEndpoint `
168-
-Credential $Credential `
169-
-Port 5986 `
170-
-UseSSL `
171-
-ScriptBlock $Script `
172-
-ArgumentList "*" `
173-
-SessionOption (New-PSSessionOption -SkipCACheck)
174-
```
175-
176-
Click Save and run to test the function
143+
```powershell
144+
# Input bindings are passed in via param block.
145+
param($Request, $TriggerMetadata)
146+
147+
# Write to the Azure Functions log stream.
148+
Write-Output "PowerShell HTTP trigger function processed a request."
149+
150+
# Note that ContosoUserPassword is a function app setting, so I can access it as $env:ContosoUserPassword
151+
$UserName = "ContosoUser"
152+
$securedPassword = ConvertTo-SecureString $Env:ContosoUserPassword -AsPlainText -Force
153+
$Credential = [System.management.automation.pscredential]::new($UserName, $SecuredPassword)
154+
155+
# This is the name of the hybrid connection Endpoint.
156+
$HybridEndpoint = "finance1"
157+
158+
$Script = {
159+
Param(
160+
[Parameter(Mandatory=$True)]
161+
[String] $Service
162+
)
163+
Get-Service $Service
164+
}
165+
166+
Write-Output "Scenario 1: Running command via Invoke-Command"
167+
Invoke-Command -ComputerName $HybridEndpoint `
168+
-Credential $Credential `
169+
-Port 5986 `
170+
-UseSSL `
171+
-ScriptBlock $Script `
172+
-ArgumentList "*" `
173+
-SessionOption (New-PSSessionOption -SkipCACheck)
174+
```
175+
176+
3. Click Save and run to test the function
177177
![Test function app](./media/functions-hybrid-powershell/test-function-hybrid.png)
178178
179-
## Managing other systems on-premises from the hybrid connection server
179+
## Managing other systems on-premises
180180
181181
You can use the connected on-premises server to connect to other servers and management systems in the local environment. This lets you manage your data center operations from Azure using your PowerShell functions. The following script registers a PowerShell configuration session that runs under the supplied credentials. These credentials need to be an administrator on the remote servers. You can then use this configuration to access other endpoints in the local server or data center.
182182
@@ -253,7 +253,7 @@ The above two scenarios enable you to connect and manage your on-premises enviro
253253

254254
You can also use Azure [virtual networks](./functions-create-vnet.md) to connect to your on-premises environment using Azure Functions.
255255

256-
## Next Steps
256+
## Next steps
257257

258258
> [!div class="nextstepaction"]
259259
> [Learn more about working with PowerShell functions](functions-reference-powershell.md)

0 commit comments

Comments
 (0)