\"\"

Next up, we\’ll need to provide hosting details. Functions on the Premium plan can integrate into a VNET, so we\’ll run this on a Premium Function.

\"\"

Next two blades ask about setting up Application Insights and some tags, and with that done, we can go ahead and deploy our Premium PowerShell Function.

\"\"

While our function is deploying – which shouldn\’t take too long – we need to add an additional subnet to our VNET that our function will be hosted from.

\"\"

We\’ll give the subnet info, and then head over to our Function app.

\"\"

Now, there are two areas where you can configure VNET integration, either in the App Service Plan, or in the Function configuration. For this integration, you\’ll want to use the Function configuration, not the App Service Plan configuration. That configuration supports a VPN based integration, which we don\’t want.

So, you\’ll want to head on over to your Function, select Platform features and hit the network button right there.

\"\"

There are a couple options there, you\’ll want to configure VNET integration on the top.

\"\"

Next, you\’ll want to add a VNET, and configure that empty subnet we just created.

\"\"
\"\"

With that done, let\’s create a Function and see how this runs from our VNET.

Creating a PowerShell Function

We\’ll build a Timer based Function for this demo.

\"\"

First thing I want to do is run an ipconfig and a ping to my other vm. This is the code I\’ll run (it\’s includes the default Functions code)

# Input bindings are passed in via param block.
param($Timer)

# Get the current universal time in the default string format
$currentUTCtime = (Get-Date).ToUniversalTime()

# The \'IsPastDue\' porperty is \'true\' when the current function invocation is later than scheduled.
if ($Timer.IsPastDue) {
    Write-Host \"PowerShell timer is running late!\"
}

# Write an information log with the current time.
Write-Host \"PowerShell timer trigger function ran! TIME: $currentUTCtime\"
ipconfig
ping 172.16.4.4


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *