<p>I would expect it to work like <code>az login</code> and open up a new tab in default browser. But somehow it doesn't work like that. I think the fix must come from azure CLI.</p>

<p>Temporarily, For <code>az aks browse</code> you can setup an environment variable on WSL.</p>

<pre><code>export BROWSER="/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"
</code></pre>

<p>In this case next when I run <code>az aks browse</code> it will open up the dashboard in new chrome tab.</p>

<p>You can use this variable to use your favorite browser. I would also add this variable to <code>.bashrc</code> or profile to be added on every session.</p>

CC BY-SA 4.0
2020-05-04T19:26:59.880Z
2020-05-04T19:26:59.880Z
Ashish Verma
<p>This is a combination of two things. You need the <code>BROWSER</code> variable and there is a bug (as of Sep-2020) where <code>az-cli</code> doesn't detect interactive session correctly (<a href="https://github.com/microsoft/WSL2-Linux-Kernel/issues/55" rel="nofollow noreferrer">https://github.com/microsoft/WSL2-Linux-Kernel/issues/55</a>)</p>
<p>So you need to modify <code>~/.bashrc</code>:</p>
<pre><code>export BROWSER=&quot;/c/Program Files (x86)/Google/Chrome/Application/chrome.exe&quot;
</code></pre>
<p>end then you can run your browser spawning commands with prefix <code>DISPLAY=:0</code> (sets that environment variable for duration of command; in this case az uses it to determine if the session is interactive and a browser should/could be spawned). So for you:</p>
<pre><code>DISPLAY=:0 az aks browse -g &lt;groupname&gt; -n &lt;clustername&gt;
</code></pre>

CC BY-SA 4.0
2020-09-08T12:38:18.773Z
2020-09-08T12:38:18.773Z
Pasi Savolainen
<p><code>az aks browse</code> works fine on my Mac Mini, but I'm trying to work with it in WSL2 Ubuntu 18.04 with Azure CLI on a Windows 10 machine.</p>

<pre><code>$ az version                      
This command is in preview. It may be changed/removed in a future release.
{
  "azure-cli": "2.1.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.1.0",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}
</code></pre>

<p>Kubernetes 1.14.8 which shouldn't make a difference given it works fine in macOS. Appears to be an issue with WSL2.</p>

<p>The first issue is running:</p>

<p><code>az aks browse -g &lt;groupname&gt; -n &lt;clustername&gt;</code></p>

<p>Just brings up the following in <code>az cli</code>:</p>

<pre><code>Proxy running on http://127.0.0.1:8001/
Press CTRL+C to close the tunnel..
</code></pre>

<p>It doesn't automatically open the browser from WSL2 like it does in macOS and Linux. So you have to <code>CTRL + Click</code> the <code>http://127.0.0.1:8001</code> which will open the browser.</p>

<p>The second issue is it only brings up a JSON response with a list of API endpoints that looks like the following:</p>

<pre><code>paths   
0   "/api"
1   "/api/v1"
2   "/apis"
3   "/apis/"
4   "/apis/acme.cert-manager.io"
5   "/apis/acme.cert-manager.io/v1alpha2"
6   "/apis/admissionregistration.k8s.io"
7   "/apis/admissionregistration.k8s.io/v1beta1"
8   "/apis/apiextensions.k8s.io"
9   "/apis/apiextensions.k8s.io/v1beta1"
10  "/apis/apiregistration.k8s.io"
11  "/apis/apiregistration.k8s.io/v1"
12  "/apis/apiregistration.k8s.io/v1beta1"
13  "/apis/apps"
14  "/apis/apps/v1"
....
</code></pre>

<p>And doesn't do anything after that.</p>

<p>Followed all of the necessary steps for <code>az login</code>, <code>az aks get-credentials</code>, and <code>RBAC</code>.</p>

<p>What gives?</p>

<kubernetes><azure><azure-kubernetes-service>
az aks browse doesn't open browser automatically on WSL and only showing JSON instead of the dashboard
cheslijones
# az aks browse doesn't open browser automatically on WSL and only showing JSON instead of the dashboard

(Asked by: username_0 on 2020-02-28)

az aks browse works fine on my Mac Mini, but I'm trying to work with it in WSL2 Ubuntu 18.04 with Azure CLI on a Windows 10 machine.
$ az version                      
This command is in preview. It may be changed/removed in a future release.
{
  "azure-cli": "2.1.0",
  "azure-cli-command-modules-nspkg": "2.0.3",
  "azure-cli-core": "2.1.0",
  "azure-cli-nspkg": "3.0.4",
  "azure-cli-telemetry": "1.0.4",
  "extensions": {}
}

Kubernetes 1.14.8 which shouldn't make a difference given it works fine in macOS. Appears to be an issue with WSL2.
The first issue is running:
az aks browse -g  -n 
Just brings up the following in az cli:
Proxy running on http://127.0.0.1:8001/
Press CTRL+C to close the tunnel..

It doesn't automatically open the browser from WSL2 like it does in macOS and Linux. So you have to CTRL + Click the http://127.0.0.1:8001 which will open the browser.
The second issue is it only brings up a JSON response with a list of API endpoints that looks like the following:
paths   
0   "/api"
1   "/api/v1"
2   "/apis"
3   "/apis/"
4   "/apis/acme.cert-manager.io"
5   "/apis/acme.cert-manager.io/v1alpha2"
6   "/apis/admissionregistration.k8s.io"
7   "/apis/admissionregistration.k8s.io/v1beta1"
8   "/apis/apiextensions.k8s.io"
9   "/apis/apiextensions.k8s.io/v1beta1"
10  "/apis/apiregistration.k8s.io"
11  "/apis/apiregistration.k8s.io/v1"
12  "/apis/apiregistration.k8s.io/v1beta1"
13  "/apis/apps"
14  "/apis/apps/v1"
....

And doesn't do anything after that.
Followed all of the necessary steps for az login, az aks get-credentials, and RBAC.
What gives?

**Tags:** kubernetes, azure, azure-kubernetes-service


---

## 2 answers

### Answer by username_1 on 2020-05-04. Score: 1 | Accepted answer

I would expect it to work like az login and open up a new tab in default browser. But somehow it doesn't work like that. I think the fix must come from azure CLI.
Temporarily, For az aks browse you can setup an environment variable on WSL.
export BROWSER="/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"

In this case next when I run az aks browse it will open up the dashboard in new chrome tab.
You can use this variable to use your favorite browser. I would also add this variable to .bashrc or profile to be added on every session.


---

### Answer by username_2 on 2020-09-08. Score: 0

This is a combination of two things. You need the BROWSER variable and there is a bug (as of Sep-2020) where az-cli doesn't detect interactive session correctly (https://github.com/microsoft/WSL2-Linux-Kernel/issues/55)
So you need to modify ~/.bashrc:
export BROWSER="/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"

end then you can run your browser spawning commands with prefix DISPLAY=:0 (sets that environment variable for duration of command; in this case az uses it to determine if the session is interactive and a browser should/could be spawned). So for you:
DISPLAY=:0 az aks browse -g  -n


---

