Accessing build and release logs in VSTS

VSTS becomes somehow better and better with each release, yet some activities are not so trivial to perform. Don't get me wrong - I'm not talking about hard-to-manage workarounds, rather subtle tricks just to make the job done.

Finding logs

It's fairly easy to download all build/release logs from the GUI - just go to the Logs tab and you will see big Downloads all logs as zip button. But what if I'd like to incorporate them in my build or release process? Unfortunately VSTS doesn't have an artifact source like e.g. TeamCity has, where you can access all information about a build. Fortunately it has a REST API, which happens to be quite helpful there.

REST for the rescue!

When you go to this site, you'll find an overview for the whole API, which VSTS shares. There are two categories - Build and Release - which are the most interesting for us now. Let's look at signatures, which are the most interesting for us:

Get build details
/
GET https://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}/timeline?api-version={version}
Get release details
/
GET https://{account}.vsrm.visualstudio.com/defaultcollection/{project}/_apis/release/releases/{releaseId}?api-version={version}

To perform those requests, Authorization header is required containing your personal token. You can obtain it by going to https://{your_instance}.visualstudio.com/_details/security/tokens.

Accessing logs

Performing above requests will return detailed info about a build or a release. What is interesting, they will return URLs to the logs related to the specific build or release. Even more - you can access specific step - e.g. output for your custom Powershell script.

Typical URLs for logs:

Build
/
https://{yourInstance}.visualstudio.com/DefaultCollection/{projectId}/_apis/build/builds/{buildId}/logs/{stepId}
Release
/
https://{yourInstance}.vsrm.visualstudio.com/{projectId}/_apis/Release/releases/{releaseId}/environments/{environmentId}/tasks/{taskId}/logs?releaseDeployPhaseId={phaseId}

Summary

Although still not without a little overhead, above solution should help you when logs produced by a build or a release are needed. URLs presented may change or differ a little, but remember, that you can get them by requesting build/release info as presented.

Overview | Mesosphere DC/OS on Azure - allowing external access

In the previous post I introduced DC/OS and provided a way to install it. There was a minor caveat related to the accessing your DC/OS instance - you need ssh to connect to it and some way to tunnel port 80 from the VM to your local computer. In fact whole infrastructure is sealed and allows connecting to it only via ssh. What if I would like to allow accessing it with any other possibility? Well, there's a simple way to do it, which I present by allowing access directly via browser on port 80. 

Inbound security rules...

The whole DC/OS isolation comes from the fact, that it resides inside a VPN, which is protected by both its security rules and a load balancer, which directs traffic inside the network. By default it allows connections via ssh on port 2200, which is further forwarded to port 22. To allow accessing it using other service, we have to perform following steps:

  1. Add a new inbound NAT rule to the load balancer to forward traffic on port 80 to port 80 inside our VM
  2. Allow accessing our network with port 80

Note - we're talking about HTTP here, nor problem to change configured port to 443 and access VM only via HTTPS.

How can I do it?

To allow access to our VM via HTTP perform following steps:

  1. Go to Azure Portal and open resource group containing an instance of Mesosphere DC/OS
  2. Find the master load balancer(usually contains something like dcos-master)
  3. Go to Inbound NAT rules and click +Add
  4. Provide a name for the rule, from the Service dropdown select any service you'd like to configure(e.g. HTTP)
  5. In Target field select a VM you're interested in
  6. Then click OK and wait a minute so the load balancer is reconfigured
  7. Now go back to DC/OS resources and find a network security group associated with the master node
  8. Go to Inbound security rules and click +Add
  9. Provide a name and select a service you're interested in
  10. Make sure Allow is selected and click OK

Once configuration is finished you should be able to access DC/OS with your browser by using your VM IP public address.