With Canopy Manage, you can automate the process of running scripts on a local or vitual machine. In this example we will demonstrate setting up a sample PowerShell script samplescript.ps1. We will call this script on the local/virtual machine using an Azure Service Bus.



Prerequisites

Custom Canopy Custom Action Template

In order to properly run a custom action on your local computer or Virtual Machine, you will need to include the following files - 


config.json
Custom_Python_Template.py
requirements.txt


These files can be found in the zip file attached at the bottom of this article.


Python

In order to run the Custom_Python_Template, the local computer or Virtual Machine will need to have Python installed. 


You can download the latest Python installation from their website.



Creating a Custom Action - Local/Virtual Machine

The following will list the steps required in creating a custom action in Canopy Manage using the Azure Service Bus. If you have already created the Azure Service Bus, then you can begin at step 3.


1) Create an Azure Service Bus and Queue

For instructions on how to do so, see Microsoft's documentation found here.

For the purposes of this demonstration we have named our Azure Service Bus queue samplescript.


2) Create Shared Access Policies

For this demonstration we will be using an access policy with Listen Only permissions, and another with Send Only permissions.

For instructions on how to do so, see Microsoft's documentation found here.


Once you have created a SendOnly SAS and a ListenOnly SAS, copy and save the Primary Connection Strings to a document for later reference.



3) Set up scripts + Canopy Manage Resources on local/virtual machine

Once you have downloaded a copy of the Canopy Manage Custom Action Template (found in the zip file attached to the bottom of this article), place these somewhere on your local/virtualmachine.

For complete instructions on this step, please see our article Set Up - Custom Action Template.



Steps to Complete - Canopy Manage

Once this is complete, you should now have a python script on your local/virtual machine listening to the Service Bus Queue for this custom action. We can now move into Canopy Manage to set up the Custom Action to be run from there. 


1) Create a Connector 

In order for Canopy Manage to send a request to the Azure Service Bus queue created earlier, we need to give the details to Canopy.


You can find information on how to set-up a Connector in Canopy Manage in our Setting Up Connectors article.


For this connector we used the connection details for our CanopySampleQueue Service Bus queue named samplequeue.


2) Create Custom Fields (optional)

In order to run the Custom Action, Canopy Manage requires a field scheme. If you don't pass any parameters to your custom script you can simply use an empty Field Scheme - however, if you want to pass parameters to your script you will first need to set them.

To do this we need to create Custom Fields. 


3) Create Custom Field Scheme

This is a block of text, formatted correctly. Insert me into the document to being a new block of formatted text.