0

I am not a developer. I am more of an infrastructure apps person with decent PowerShell. I do have history with .NET & Java but that was a lifetime ago.

Powershell is still experimental for http-triggered Azure Functions for example, but for cosmosDB-triggered, it is not even an option in the portal as of yet. I have been able to write an http-triggered function in powershell that runs AD cmdlets against an Active Directory instance in Azure. The cmdlets to AD read and write operations.

The goal is to achieve same with a CosmosDB-triggered function.

Q1. Is there a way to write a CosmosDB-triggered function in PowerShell?

Q2. If the only options available remain C#/JavaScript, how can I achieve AD read/write natively in those languages or better, call a PowerShell function that has been uploaded to the Azure function's directory using Kudu/FTP?

Bandz
  • 253
  • 4
  • 15
  • 1
    You can totally call a PowerShells script from C# or JavaScript. You could also use the .NET mangement libraries - here's a sample project that shows how to do (almost) everything AD in .NET - https://www.codeproject.com/Articles/18102/Howto-Almost-Everything-In-Active-Directory-via-C – Chris Anderson Sep 27 '18 at 22:18
  • If you dont want to code, maybe have a look at logic app ? Or create a simple `cosmobdtrigger` that will trigger your powershell httptrigger ? – Thomas Sep 28 '18 at 22:57
  • @ChrisAnderson-MSFT Thank you very much!! How will I go about calling my powershell script from JS? I am sorry if this seems a silly Q but like i said i am not a developer. The article you sent referenced looks excellent! I will take a look and try my hands on some C# – Bandz Sep 30 '18 at 02:56
  • @Thomas Thank you! I will try my hands on Logic Apps. I didn't know one could chain Azure functions like so - CosmosDBTrigger => HttpTrigger. I'll give this a go as well and report back – Bandz Sep 30 '18 at 03:02
  • @Rock - I'll point you to this SO question as a starter place. Feel free to start a new question if you want a full answer. https://stackoverflow.com/questions/5775088/how-to-execute-an-external-program-from-within-node-js – Chris Anderson Oct 01 '18 at 18:19
  • @ChrisAnderson-MSFT I was able to call call a powershell function from a cosmosdb-triggered fucntion in JS. Thank you for your help – Bandz Oct 02 '18 at 19:17
  • @Thomas Thank you both!! – Bandz Oct 02 '18 at 19:17
  • @Rock, feel free to share your solution once implemented – Thomas Oct 02 '18 at 20:37

0 Answers0