Use Powershell to access API behind Data-Gateway - powershell

I have been trying to make a REST request from within a Powershell script to a service behind a Data-Gateway (deployed on premise).
I couldn't find any information about any Powershell modules that would allow us to contact Data-Gateway services via REST.
Is there any way to consume the services behind the Data-Gateway using REST requests ? (without using the Power Bi or Power Apps API).
Any tips would be highly appreciated.

Related

API Gateway for Powershell scripts

I would like to be able to call Powershell scripts using a REST API. (Please note that I am describing the _opposite_ of calling a REST API from Powershell.) Are there any prebuilt API gateways that support this use case? I've looked at Ocelot, but it currently only acts as a gateway to other REST APIs. Ideally I would simply design my Powershell script functions to follow a defined interface pattern, put the files into a defined directory, and the API gateway would either immediately make those functions available as REST API calls or with minimal configuration.
EDIT: To clarify, I am looking for something self hosted, not cloud based. I haven't found anything yet that is exactly what I need, I may create something myself.
You can try AWS Lambda and API gateway integration.
Here is an example: https://aws.amazon.com/blogs/developer/creating-a-powershell-rest-api/
Amazon offer 12 month free tier plan for this.
A couple of options. If you are on Azure you could expose your Powershell Scripts through Azure Automation :
https://learn.microsoft.com/en-us/azure/automation/automation-webhooks
That'd be a lightweight way of having your scripts enabled through a HTTP POST scenario.
You could also combine or mix it with adding API Management in front to support various scenarios (adding GET/PUT/DELETE support e.g.) or even automate or proxy more things. API Management could of course also be automated.
https://azure.microsoft.com/en-us/services/api-management/
You could also create a folder structure with modules & sub-functions and create a full REST API by using Azure Functions with PowerShell:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell
The latter would also be able to execute in containers & in the supported Azure Function
runtimes.

Get relation between Hosts and Datastores using vSphere Automation REST API

I'm trying to create VM using vSphere Automation SDK REST API and vRealize Orchestrator but the workflow in Orchestrator I'm using needs the host and datastore on which to create the VM (I'm cloning a VM using a template).
My problem is that my datastores are not shared by all clusters (and hosts) so I need to be careful to create a VM with a matching host and datastore.
With the vSphere Automation SDK REST API I can easily get the list of hosts and datastores (here's the doc I found : https://code.vmware.com/doc/preview?id=4645), but none of the "list" or "get" requests give me links between hosts and datastores.
How can I get the relations between my datastores and my hosts so that I can call Orchestrator with the correct parameters ?
Thank you.
Check out https://github.com/doublecloudinc/vim-rest-api
The REST APIs supports FULL features of vSphere APIs, and scales across many vCenter/ESXi servers. You can list all the host and pick one to get its datastore property easily with a couple of REST calls.
Also, vBrownBag tech talk: https://youtu.be/EpMlP27gEEM
Disclaimer: I am the creator of the REST APIs.

Azure Site Recovery - REST API, Powershell and Automation

Has anyone come up with a complete solution to protect and replicate VMs from on-prem (either VMware or HyperV) to Azure using either the REST API or the Powershell module?
I recently completed a POC with ASR and was able to replicate a couple dozen VMs associated with three different applications. I replicated out of VMware and into Azure. I was able to failover and failback successfully.
I did all of the POC work using the GUI (portal.azure.com). Now I have to figure out how to protect ~2000 VMs and there is no way that I am going to do that with the GUI. But the MS documentation has me running in circles.
(https://learn.microsoft.com/en-us/azure/site-recovery/)
It would be very helpful if any of you can share the sequence of steps to protect and replicate a VM. The MS documentation does not lay out how the various components (fabrics, protection policies, protection containers, protection items, etc.) are related to each other.
I do not need specific syntax. The documentation does a passable job of detailing the syntax. I could use some guidance on the task sequence.
If it helps to understand the bigger picture, my intention is to use a System Center Orchestrator runbook to ingest a CSV list of VMs, parse that out into input for the Azure REST API / Powershell, and then enable protection.
Thanks in advance for any assistance or guidance that you are able to provide.
You can find recovery service API documentation here:
https://learn.microsoft.com/en-us/rest/api/recoveryservices/
When you have one definition put in place(manually from portal), you may also be able to study it from resource.azure.com to see how properties are composited. *not all resource available thru this portal
After that, you should be able to create template for either REST call or Resource Manager, depending on preference.

Azure REST API - getting identity data

In Amazon cloud API there is the possibility to get identity data, meaning data from the running instance - on which region it is, dns ....
is there the same option in Azure? as I am creating management system in which the server is installed on a virtual machine and I need to know to which region it is related, all this using REST API
In Azure you can use Azure API Management REST API to get all sort of information for Azure:
ex:
Lists all of the resources in a subscription:
https://management.azure.com/subscriptions/{subscription-id}/resources?$top={top}$skiptoken={skiptoken}&$filter={filter}&api-version={api-version}
For the complete documentation look at this page here:
https://msdn.microsoft.com/en-us/library/azure/dn776326.aspx
You can do similar things using Powershell scripts as well.

Add many domains to an azure web site

I'm migrating a pretty serious multi-tenant application to Azure, and one of the challenges I see coming is that it hosts over a hundred domains.
On the Azure side, the only way I see to add a custom domain is hand-entering them via the portal. I would really like to script this out with Azure PowerShell or (perhaps less desirable for this one-off operation) one of the .Net APIs.
I did find this, which shows that it can be done with one of the REST APIs: Add a domain to an Azure web site via code
Is there anything for PowerShell?
you can use -
Set-AzureWebsite -Name "ramisample" -HostNames #('www.abc.com', 'abc.com')
Make sure you point the CNAME records before adding them as domains.