0

What do I have?

I have already setup deployment of my ASP.NET Core app to my IIS. The IIS app itself is not visible from internet, because it is behind firewall.

Question

How can I ping my app from the server where it is running (so that it will perform HTTP GET to localhost) and report back to Azure DevOps? Ideally using existing Task

I could probably write some PowerShell, but I would really like to use exiting solution

1
  • Hi, is there any updates for this question? Please feel free to let me know whether my answer helps~ Commented Jan 15, 2021 at 1:19

1 Answer 1

0

As of this time, however, I'm afraid there isn't a built-in task can perfectly solve your question.

There is an Invoke REST API task that can invoke HTTP APIs and parse the response. But this task can be used in only an agentlees job, in other words, you cannot use this task unless you set your firewall to allow access from Azure DevOps.

Update: Using PowerShell task

Prerequisites: You need to use self-hosted agent so that you can access your application within your firewall.

The following is demonstrated using YAML pipeline. The steps for classic UI pipeline is roughly the same.

If you just want to get the response body:

Just use a Powershell task and send your web request:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      ...
      Invoke-RestMethod ...

If you want to save the response body as a variable:

Step 1. Set a variable:

variables:
  result: null

Step 2. Use the PowerShell task to send a HTTP request and update the variable:

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      ...
      $response = Invoke-RestMethod ...
      Write-Host "##vso[task.setvariable variable=result;]$response"

Step 3. Then the value of $($env:RESULT) is the response body of your web request, and you can use it in subsequent tasks.

2
  • The powershell approach would work? How is the output from powwrshell reported back to Azure DevOps?
    – Liero
    Commented Jan 6, 2021 at 12:10
  • @Liero Yes, the PowerShell task can meet your requirement. I have updated my answer for you~ Commented Jan 7, 2021 at 2:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.