I have a azure function app in powershell, dedicated to kubernetes functions.

There are multiple functions but on each of them, the first thing we do is something like this.

```
 az login --service-principal -u $usr -p $pwd --tenant $tenant

 $config = $HOME + "/.kube/$tenant";

 az account set --subscription $subscription
 az aks get-credentials --overwrite-existing --name $cluster --resource-group $rg --admin --file $config
 kubectl config set-context --current --namespace=$tenant

```

This sets the contexts we will be working with on our next kubectl commands.

We do it, because we have multiple clusters on multiple regions, so everytime we get a call on the function app, we need to connect to the given cluster to work on it.

The problem with this is when we get 2 requests at exactly the same time for 2 different clusters and the earliest call will get its context overriden and be executing kubectl commands on the incorrect cluster.
Is there a way to isolate each call or a solution to this?