Adrian Hynes

Nov 8, 2020

3 min read

Creating an Azure az cli extension for AKS Non Interactive Auth

Introduction

In the previous 4 part article series https://adrianhynes.medium.com/connecting-to-an-aks-cluster-non-interactivity-part-1-260c9451b6a7, we went through how Authentication and Authorization works in your AKS RBAC enabled cluster, as well as how you can Non Interactively connect to your AKS cluster.

Project Structure and Files

Let’s first create our required project structure. You can check out Microsoft’s real examples here for some help on your az cli extension journey: https://github.com/Azure/azure-cli-extensions/tree/master/src

Steps

I’ve pretty much lifted and shifted the code from our AKS Non Interactive Auth project in the previous series from here https://github.com/aido123/azaksauth to here https://github.com/aido123/aksauth/blob/master/azext_aksauth/custom.py.

  1. Clone down https://github.com/aido123/aksauth
  2. Create our python wheel
python setup.py bdist_wheel
az extension add — source C:\Users\Adrian\aksauth\dist\aksauth-0.0.1-py2.py3-none-any.whl
az aksauth connect --resource-group adrian-group --subscription xxxxxx–aaaa–bbbb-cccc–zzzzzzz --cluster-name adrian-cluster --tenant 00000000–2222–5555–9999-222222 --username clusteruser@mydmn.com --password “hard2Guess”

Appendix: Reference Material