Skip to content

Instantly share code, notes, and snippets.

@kkamegawa
Created December 18, 2018 22:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkamegawa/694b0da6a904787e1958a1a695e2f3fe to your computer and use it in GitHub Desktop.
Save kkamegawa/694b0da6a904787e1958a1a695e2f3fe to your computer and use it in GitHub Desktop.
Azure Pipeline task to call Azure REST API
steps:
- powershell: |
$azuretoken=''
$subscriptionID = ''
$location = 'Japan%20East'
$method = "GET"
$apiurl = "https://management.azure.com/subscriptions/"+$subscriptionID+"/providers/Microsoft.Compute/locations/"+ $location +"/runCommands?api-version=2017-03-30"
$authHeader = "Bearer " + $azuretoken
$requestHeader = @{
"Authorization" = $authHeader
"Accept" = "application/json"
}
$contentType = "application/json;charset=utf-8"
$apires = Invoke-WebRequest -Uri $apiurl -Method $method -Headers $requestHeader -ContentType $contentType
#Display the responce body
$apires.Content
displayName: 'PowerShell Script'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment