Skip to content

creates local files for easy start with Azure Functions

Notifications You must be signed in to change notification settings

iricigor/EasyAzureFunction

Repository files navigation

EasyAzureFunction

Build status latest version downloads

Introduction

This PowerShell module helps you to create local files for easy start with Azure Functions. See How to Use section below for a quick start.

If you already have your Azure Function created (or you know how to do it), then just run New-AzFC <MyCommand> and upload generated files to your function! Simple as that! Command will generate two files:

  • index.html - simple web page that enables you to enter input values for commandlet parameters (left/first page in screenshots below)
  • run.ps1 - actual script that is executed inside of Azure Function
    • without parameters it returns index.html
    • with parameters, it executes specified command on web server and returns result (right/second page in screenshots below)

Module is tested on both Windows PowerShell and on PowerShell Core.

If you want to learn how PowerShell Azure Function works, check auto-generated run.ps1 files under Examples folders. For more information on getting started with Azure Functions, check this introduction page.

How to install

You can install this module from PowerShell Gallery (preferred way) or by cloning GitHub repository. Module is tested both on Windows PowerShell and PowerShell Core.

From PSGallery

Find-Module EasyAzureFunction -Repository PSGallery | Install-Module -Scope CurrentUser -Force

From GitHub

git clone https://github.com/iricigor/EasyAzureFunction.git      # Clone this repository
Import-Module .\EasyAzureFunction\EasyAzureFunction.psd1 -Force  # Import module

How to use

In order to fully use this module, you need have Azure function and do two simple steps. Azure Function should be HTTP triggered PowerShell function. Check more info here.

1. Run command and generate files locally

 New-AzureFunctionCode -Command Get-Process -Path C:\GP

You can select any PowerShell command instead of Get-Process. You will get two files in folder: run.ps1 and index.html.

2. Copy generated files to your Azure function

In AzF you created, replace content of default 'run.ps1' with the one you created. Under files section (far right), click on Add and create new file named 'index.html' and replace its content also.

Advanced users can do these actions also via FTP.

Published commands

Module publishes two new commandlets:

Examples

Here are some basic examples for built in PowerShell commands. All of these links will open Azure Functions web page, so just click it and see it in action.

  • Get-Command - type Pester as value for parameter -Module
  • Get-Process - run without any parameters to see all visible processes
  • Get-Module - select -ListAvailable and add Pester,Dism in Name field under it

And here are some examples using non-Get functions

Examples Screenshots

Easy Azure Function example - Get-Command -Module Pester example Easy Azure Function example - Get-Process

Known limitations

  • Generated html file only supports strings in input fields. If a command expects certain complex object (i.e. PSCredentials, PSSession, etc.), it will fail
  • Generated html does only basic parsing of arrays (split on comma), so it might not work always as expected

Thanks list

About

creates local files for easy start with Azure Functions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published