A Microsoft cloud service that enables deployment of Azure services across hybrid and multicloud environments.
Hello 승록 이, As per your query you are facing issue during deployment, the step using az connectedk8s proxyfails with a port conflict error: ERROR: Port <port> is already in use
This causes the proxy to terminate, leading to empty kubeconfig, and subsequent failures in kubectl / helm.
The failure occurs because the az connectedk8s proxy command is being invoked multiple times within the same pipeline job, causing port collisions.
- Azure CLI proxy fails if another instance is already running or if the port is already in use
- The command supports a default listening port (commonly ~47011) and can be overridden via
--port
In your pipeline:
- Proxy is started in background (
&) - Previous instance is not terminated
- Second invocation > port already in use > failure
Your analysis is correct on all points, and I can confirm the specifics:
-
az connectedk8s proxyuses 47011 as the listen port and 47010 as an internal port (hardcoded defaults). A second proxy in the same job collides on these — that's your error. - Microsoft-hosted agents get a fresh isolated VM per job, so cross-pipeline contention is impossible. The conflict is intra-job — the proxy is started more than once in one job (very likely because your job loops over multiple apps/namespaces like BIZ/COP and includes
arc-proxy.ymlper iteration), or a prior proxy in the job didn't exit first. - The cascade (
current-context is not set→ helmflags cannot be placed before plugin name) is all secondary to the dead proxy + missing liveness check.
Recommended fix = both of your options plus a liveness gate:
- Start one proxy per job (outside the per-app loop) and kill it in a
condition: always()teardown step so nothing is orphaned on retries. - Add a liveness gate: after launching the proxy with
&, loopkubectl get ns(with the proxy's--filekubeconfig) until it succeeds, andkill -0 $PIDto fail fast if it died. This turns the silent cascade into an immediate, clear failure. - Only if you truly need concurrent proxies in one job, give each a unique
--portand its own--filekubeconfig (space the ports out; don't reuse 47010). - Helm hygiene:
helm list --kube-context "$CTX"(flag after subcommand) and guard: "${KUBE_CONTEXT:?not set}".
Also: upgrade the connectedk8s extension on the agent (az extension add --upgrade -n connectedk8s). The cleanest design for multi-app deploys is one proxy → loop deployments against that single kubeconfig via --kube-context, which sidesteps the port issue entirely.
Refs:
az connectedk8s proxy https://learn.microsoft.com/cli/azure/connectedk8s#az-connectedk8s-proxy
port 47011 shown at https://learn.microsoft.com/azure/aks/aksarc/aks-create-clusters-cli#connect-to-the-kubernetes-cluster
Hope this helps! thank you