{"id":12956,"date":"2017-02-24T12:16:33","date_gmt":"2017-02-24T20:16:33","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/?p=12956"},"modified":"2019-02-18T12:38:02","modified_gmt":"2019-02-18T19:38:02","slug":"using-powershell-modules-in-azure-functions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/using-powershell-modules-in-azure-functions\/","title":{"rendered":"Using PowerShell Modules in Azure Functions"},"content":{"rendered":"<p>Previously, I <a href=\"https:\/\/blogs.msdn.microsoft.com\/powershell\/2017\/02\/09\/building-a-github-dashboard-using-powershell-azurestoragetable-azurefunction-and-powerbi\/\">blogged <\/a>about how I created\u00a0<a href=\"http:\/\/aka.ms\/psgithubbi\">PowerShell GitHub Dashboard<\/a>\u00a0using Azure Functions to run a <a href=\"https:\/\/www.powershellgallery.com\/packages\/PSGitHubStats\">PowerShell script<\/a>\u00a0and didn&#8217;t use PowerShell Modules as I didn&#8217;t find an easy way to do it with Azure Functions. \u00a0<a href=\"https:\/\/twitter.com\/sstranger\">Stefan <\/a><a href=\"https:\/\/twitter.com\/sstranger\/status\/830016639815077888\">informed <\/a>me that you can easily do it using FTP! \u00a0Today, I&#8217;m publishing a guest blog post that Stefan authored that walks you through how to use PowerShell Modules in Azure Functions!<\/p>\n<hr \/>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/social.msdn.microsoft.com\/profile\/Steve+Lee+%5BMSFT%5D\">Steve Lee<\/a> published a couple of blog posts about how he created a <a href=\"https:\/\/devblogs.microsoft.com\/powershell\/powershell-open-source-community-dashboard\/\">PowerShell Open Source Community Dashboard<\/a> in <a href=\"http:\/\/powerbi.com\/\">PowerB<\/a>i. In his last <a href=\"https:\/\/blogs.msdn.microsoft.com\/powershell\/2017\/02\/09\/building-a-github-dashboard-using-powershell-azurestoragetable-azurefunction-and-powerbi\/\">blog post<\/a> he explained how he used PowerShell, Azure StorageTable, Azure Function and PowerBi to create the Dashboard.<\/p>\n<p>In his solution, the Azure Function is executing a PowerShell script which calls the Github REST APIs and stores the result in an Azure StorageTable, finally queried by PowerBI.<\/p>\n<p>Azure Functions and especially PowerShell Azure Functions are something I&#8217;m interested in for the last couple of weeks. I already wrote a blog post called &#8220;<a href=\"https:\/\/blogs.technet.microsoft.com\/stefan_stranger\/2017\/01\/29\/powershell-azure-functions-lessons-learned\/\">PowerShell Azure Functions lesson learned<\/a>&#8220;. If you are just starting to explore PowerShell Azure Functions I would highly recommend to look.<\/p>\n<p>In his blog post Steve mentions that within Azure Functions you only can run a PowerShell script and that you cannot use PowerShell modules within your PowerShell Azure Function. Well that&#8217;s not correct, there is a way to use PowerShell Modules within your PowerShell Azure Function.<\/p>\n<p>In this blog post I&#8217;ll explain how you could start using PowerShell Modules in Azure Functions. I&#8217;ve to give credit to <a href=\"https:\/\/twitter.com\/david_obrien\">David O&#8217;Brien<\/a> for introducing PowerShell Azure Functions to me.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Which PowerShell Modules are available with a PowerShell Azure Function? <\/strong><\/p>\n<p>First you need to create an Azure Function. On the <a href=\"https:\/\/github.com\/Azure\/Azure-Functions\">Github page about Azure Functions<\/a> you can find all the info to get started.<\/p>\n<p>After creating your PowerShell Azure Function, you can start exploring the current available PowerShell Modules just like you would do on your local machine.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"539\">\n<blockquote><p>Get-Module -ListAvailable | Select-Object Name, Version | Sort-Object -Property Name<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Let first start with retrieving the currently installed PowerShell Modules in Azure Functions by outputting the result to the log window in Azure Functions. We are also interested in the locations of the PowerShell Modules.<\/p>\n<table width=\"551\">\n<tbody>\n<tr>\n<td width=\"366\">\n<blockquote><p>Write-Output &#8216;Getting PowerShell Module&#8217;<\/p>\n<p>$result = Get-Module -ListAvailable |<\/p>\n<p>Select-Object Name, Version, ModuleBase |<\/p>\n<p>Sort-Object -Property Name |<\/p>\n<p>Format-Table -wrap |<\/p>\n<p>Out-String<\/p>\n<p>Write-output `n$result<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Copy above PowerShell code into the run.ps1 Azure Function and click on Run.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic1.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic1.png\" alt=\"pic1\" width=\"1538\" height=\"334\" class=\"alignnone wp-image-12965 size-full\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic1.png 1538w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic1-300x65.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic1-768x167.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic1-1024x222.png 1024w\" sizes=\"(max-width: 1538px) 100vw, 1538px\" \/><\/a><\/p>\n<p>If we expand the log window we see that the following PowerShell Modules are installed.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic2.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic2.png\" alt=\"pic2\" width=\"1228\" height=\"560\" class=\"alignnone wp-image-12975 size-full\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic2.png 1228w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic2-300x137.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic2-768x350.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic2-1024x467.png 1024w\" sizes=\"(max-width: 1228px) 100vw, 1228px\" \/><\/a><\/p>\n<p>I prefer to see the output result in my PowerShell ISE so I often use the following code in my Azure Function.<\/p>\n<table width=\"742\">\n<tbody>\n<tr>\n<td width=\"419\">\n<blockquote><p>$result = Get-Module -ListAvailable |<\/p>\n<p>Select-Object Name, Version, ModuleBase |<\/p>\n<p>Sort-Object -Property Name |<\/p>\n<p>Convertto-Json -depth 1<\/p>\n<p>Out-File -encoding Ascii -FilePath $res -inputObject $Result<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>You can now call your Azure Function from the PowerShell ISE with the following PowerShell script.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"1032\">\n<blockquote><p>$HttpRequestUrl = &#8216;[enter azure function url here]&#8217;<\/p>\n<p>Invoke-RestMethod -Uri $HttpRequestUrl -Method POST -ContentType &#8216;application\/json&#8217; | ConvertFrom-Json<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>This results in the following.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic3.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic3.png\" alt=\"pic3\" width=\"1556\" height=\"377\" class=\"alignnone wp-image-12985 size-full\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic3.png 1556w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic3-300x73.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic3-768x186.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic3-1024x248.png 1024w\" sizes=\"(max-width: 1556px) 100vw, 1556px\" \/><\/a><\/p>\n<p>The next step is checking the Environment variable PSModulePath to find out where all the PowerShell Modules are stored.<\/p>\n<table width=\"748\">\n<tbody>\n<tr>\n<td width=\"487\">\n<blockquote><p>$result =\u00a0 $env:psmodulepath |<\/p>\n<p>Convertto-Json -depth 1<\/p>\n<p>Out-File -encoding Ascii -FilePath $res -inputObject $Result<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic4.png\">\n<img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic4.png\" alt=\"pic4\" width=\"1577\" height=\"95\" class=\"alignnone size-full wp-image-12995\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic4.png 1577w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic4-300x18.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic4-768x46.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic4-1024x62.png 1024w\" sizes=\"(max-width: 1577px) 100vw, 1577px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Where can we store our own PowerShell Modules? <\/strong><\/p>\n<p>Well because Function apps are built on App Service, all the deployment options available to standard web apps are also available for function apps \ud83d\ude42 The App Service has a deployment option to configure deployment credentials.<\/p>\n<p><strong>Remark:<\/strong> When you configure a FTP\/Deployment username and password this applies to all your Web Apps within your Microsoft Azure Account.<\/p>\n<p>To upload PowerShell Modules via FTP we need to configure the <strong>Function App Settings<\/strong>.<\/p>\n<p>Select Function app settings -&gt; Go to App Service Settings to configure the Deployment credentials.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic5.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic5.png\" alt=\"pic5\" width=\"1228\" height=\"696\" class=\"alignnone size-full wp-image-13005\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic5.png 1228w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic5-300x170.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic5-768x435.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic5-1024x580.png 1024w\" sizes=\"(max-width: 1228px) 100vw, 1228px\" \/><\/a><\/p>\n<p>Next select in the App Service settings for the Azure Function Deployment Credentials.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic6.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic6.png\" alt=\"pic6\" width=\"250\" height=\"410\" class=\"alignnone size-full wp-image-13015\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic6.png 250w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic6-183x300.png 183w\" sizes=\"(max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>Enter a FTP\/deployment username and password.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic7.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic7.png\" alt=\"pic7\" width=\"624\" height=\"366\" class=\"alignnone size-full wp-image-13025\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic7.png 624w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic7-300x176.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>Now you are ready to connect via a FTP client to your Azure Function (Web App).<\/p>\n<p>You can find the FTP Hostname in your Azure Portal.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic8.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic8.png\" alt=\"pic8\" width=\"1316\" height=\"319\" class=\"alignnone size-full wp-image-13035\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic8.png 1316w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic8-300x73.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic8-768x186.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic8-1024x248.png 1024w\" sizes=\"(max-width: 1316px) 100vw, 1316px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Connect via FTP Client to Azure Function Web App<\/strong><\/p>\n<p>Open your favorite FTP Client and connect to the FTP endpoint. I&#8217;m using <a href=\"https:\/\/filezilla-project.org\/\">Filezilla<\/a> as my favorite FTP client.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic9.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic9.png\" alt=\"pic9\" width=\"760\" height=\"304\" class=\"alignnone size-full wp-image-13045\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic9.png 760w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic9-300x120.png 300w\" sizes=\"(max-width: 760px) 100vw, 760px\" \/><\/a><\/p>\n<p>Copy and past host, username from App Service overview page on the Azure Portal and click on Quickconnect.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic10.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic10.png\" alt=\"pic10\" width=\"1366\" height=\"699\" class=\"alignnone size-full wp-image-13055\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic10.png 1366w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic10-300x154.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic10-768x393.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic10-1024x524.png 1024w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/a><\/p>\n<p>After connecting via FTP we can create a new Module folder under wwwroot\\HttpTriggerPowerShellDemo (or your name of your Azure Function). Create a new directory called Modules.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic11.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic11.png\" alt=\"pic11\" width=\"858\" height=\"390\" class=\"alignnone size-full wp-image-13065\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic11.png 858w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic11-300x136.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic11-768x349.png 768w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/a><\/p>\n<p>After the creation of the Modules directory we can upload our PowerShell Module(s) to this remote directory. Make sure you have first downloaded your module to your local system. We are going to upload my favorite PowerShell Module <a href=\"https:\/\/www.powershellgallery.com\/packages\/wunderlist\/\">Wunderlist<\/a>.<\/p>\n<p>Drag and drop the local Wunderlist module to the remote Modules folder.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic12.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic12.png\" alt=\"pic12\" width=\"1000\" height=\"427\" class=\"alignnone size-full wp-image-13075\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic12.png 1000w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic12-300x128.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic12-768x328.png 768w\" sizes=\"(max-width: 1000px) 100vw, 1000px\" \/><\/a><\/p>\n<p>You have now uploaded the Wunderlist module to your Azure Function.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>How can we start using this module in our Azure Function?<\/strong><\/p>\n<p>First we can check if we can load the module and return the help from one of the Functions in the Module.<\/p>\n<p>Use the following code in your Azure Function:<\/p>\n<table width=\"1121\">\n<tbody>\n<tr>\n<td width=\"723\">\n<blockquote><p>Write-Output &#8220;Loading Wunderlist Module&#8221;<\/p>\n<p>import-module &#8216;D:\\Home\\site\\wwwroot\\HttpTriggerPowerShellDemo\\Modules\\Wunderlist\\1.0.10\\Wunderlist.psm1&#8217;<\/p>\n<p>$Result = Get-Help Get-WunderlistUser | Out-String<\/p>\n<p>Write-Output $Result<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Result:<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic13.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic13.png\" alt=\"pic13\" width=\"666\" height=\"510\" class=\"alignnone size-full wp-image-13085\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic13.png 666w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic13-300x230.png 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/a><\/p>\n<p>To get my Wunderlist Module working you need to also configure a ClientId and AccessToken. For more information you can check the following blog post <a href=\"https:\/\/blogs.technet.microsoft.com\/stefan_stranger\/2016\/08\/08\/using-wunderlist-module-in-azure-automation-part-2\/\">Using Wunderlist Module in Azure Automation\u2013Part 2<\/a>. Long story short, you need to store the ClientID and AccessToken as Environment variables using the Web App Settings.<\/p>\n<p>Go to Function App Settings and click on Configure app settings.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic14.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic14.png\" alt=\"pic14\" width=\"1225\" height=\"249\" class=\"alignnone size-full wp-image-13095\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic14.png 1225w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic14-300x61.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic14-768x156.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic14-1024x208.png 1024w\" sizes=\"(max-width: 1225px) 100vw, 1225px\" \/><\/a><\/p>\n<p>Add ClientID and AccessToken variables in the Application settings. Don&#8217;t forget to Save the new settings.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic15.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic15.png\" alt=\"pic15\" width=\"583\" height=\"652\" class=\"alignnone size-full wp-image-13105\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic15.png 583w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic15-268x300.png 268w\" sizes=\"(max-width: 583px) 100vw, 583px\" \/><\/a><\/p>\n<p>We can now use these Environment variables in our Azure Function without any extra configuration needed.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic16.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic16.png\" alt=\"pic16\" width=\"923\" height=\"616\" class=\"alignnone size-full wp-image-13115\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic16.png 923w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic16-300x200.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic16-768x513.png 768w\" sizes=\"(max-width: 923px) 100vw, 923px\" \/><\/a><\/p>\n<p>As a final test, we are going to test if we can create a new Wunderlist Task from our Azure Function.<\/p>\n<p>By using a HTTP Post method with a body value as input for our Function we can do some more advanced Azure Function activities.<\/p>\n<p>Use the following code in your Azure Function:<\/p>\n<table width=\"1240\">\n<tbody>\n<tr>\n<td width=\"723\">\n<blockquote><p># Get the input request<\/p>\n<p>$in = Get-Content $req -Raw | ConvertFrom-Json<\/p>\n<p>Write-Output $in.Title<\/p>\n<p>&nbsp;<\/p>\n<p># Import Wunderlist Module<\/p>\n<p>Write-Output &#8220;Loading Wunderlist Module&#8221;<\/p>\n<p>import-module &#8216;D:\\Home\\site\\wwwroot\\HttpTriggerPowerShellDemo\\Modules\\Wunderlist\\1.0.10\\Wunderlist.psm1&#8217;<\/p>\n<p>&nbsp;<\/p>\n<p># Create new Wunderlist Task<\/p>\n<p>Write-Output &#8220;Creating Wunderlist Task&#8221;<\/p>\n<p>$Result = New-WunderlistTask -listid &#8216;267570849&#8217; -title $in.Title<\/p>\n<p>Write $Result<\/p><\/blockquote>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic17.png\"><img decoding=\"async\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/02\/pic17.png\" alt=\"pic17\" width=\"1281\" height=\"645\" class=\"alignnone size-full wp-image-13125\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic17.png 1281w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic17-300x151.png 300w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic17-768x387.png 768w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2017\/02\/pic17-1024x516.png 1024w\" sizes=\"(max-width: 1281px) 100vw, 1281px\" \/><\/a><\/p>\n<p>Hope you have now learned how to use your &#8220;own&#8221; PowerShell modules within your PowerShell Azure Functions.<\/p>\n<p>Stefan Stranger\nSecure Infrastructure Consultant\nMicrosoft<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Previously, I blogged about how I created\u00a0PowerShell GitHub Dashboard\u00a0using Azure Functions to run a PowerShell script\u00a0and didn&#8217;t use PowerShell Modules as I didn&#8217;t find an easy way to do it with Azure Functions. \u00a0Stefan informed me that you can easily do it using FTP! \u00a0Today, I&#8217;m publishing a guest blog post that Stefan authored that [&hellip;]<\/p>\n","protected":false},"author":685,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12956","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Previously, I blogged about how I created\u00a0PowerShell GitHub Dashboard\u00a0using Azure Functions to run a PowerShell script\u00a0and didn&#8217;t use PowerShell Modules as I didn&#8217;t find an easy way to do it with Azure Functions. \u00a0Stefan informed me that you can easily do it using FTP! \u00a0Today, I&#8217;m publishing a guest blog post that Stefan authored that [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/12956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/685"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=12956"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/12956\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=12956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=12956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=12956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}