Questions about Using Powershell to creating a REST Service.

JC0133

Senior member
Nov 2, 2010
201
1
76
We are using powershell 5.1 and Azure/AzureRM.

So I created a post asking a different question about a similar topic, not sure if I should have just posted to that one. If so I am sorry.

So I am working a internship first one and I need to use powershell to create a dummy service, to send to our APIM (API manager).

Not sure if I need to do something in APIM or not to be honest.

The point is to back get back a HTTP response that is 200. I believe this is a way of checking if the APIM is up and running correctly.

Very very new to using REST and Powershell. So any help would be appreciated.

I tried to use Azure API Management Cmdlets hoping one of them simply returned the HTTP status of the APIM but I couldn't find one that does.

So I have been trying to find videos of how to create a service using powershell, I keep finding videos of how to simple run the GET method.

So if anybody can help me I would appreciate it. Whether it is examples, tutorials or videos.
 

mxnerd

Diamond Member
Jul 6, 2007
6,799
1,103
126

KentState

Diamond Member
Oct 19, 2001
8,397
393
126
Sounded like the OP just wanted to do a simple GET request against their APM service. Otherwise I'm confused as well.


This was an example from the doc that might related to what you are trying.

https://docs.microsoft.com/en-us/po...l.utility/invoke-restmethod?view=powershell-6

Code:
$Cred = Get-Credential
$Url = "https://server.contoso.com:8089/services/search/jobs/export"
$Body = @{
    search = "search index=_internal | reverse | table index,host,source,sourcetype,_raw"
    output_mode = "csv"
    earliest_time = "-2d@d"
    latest_time = "-1d@d"
}
Invoke-RestMethod -Method 'Post' -Uri $url -Credential $Cred -Body $body -OutFile output.csv
 

Cogman

Lifer
Sep 19, 2000
10,284
138
106
OP, I have to ask, why powershell?

I ask because it isn't really all that popular of a technology. Because you mentioned Azure, I'm also wondering why you aren't using docker? You can use pretty much any tech in that.

If the objective is to call a rest endpoint, then curl is probably the simplest way to do that.
If the objective is to create a server, then I'd start with a scripting language (python is pretty popular) and if I needed it to be fast I'd write it in Java.
 

JC0133

Senior member
Nov 2, 2010
201
1
76
Thanks for all of your help. I finished my project.

Um I was just told to user powershell lol.