I am working on automating certain tasks related to Azure Kubernetes.
For this, I want to connect to AKS to list pods and to get live logs which we get through kubectl.
However, when I import the azure module as follows
from azure.mgmt.containerservice import ContainerServiceClient
or
from azure.mgmt.kubernetesconfiguration import SourceControlConfigurationClient
It throws exception that
ModuleNotFoundError: No module named ‘azure.mgmt’
I have properly installed this module in virtual env which gets listed on the pip3 list
.
Is there any new way of working with AKS or container service?
Edit –
Output of pip3 list is –
Package Version
---------------------------------- ---------
azure-common 1.1.28
azure-core 1.26.3
azure-identity 1.12.0
azure-mgmt-core 1.3.2
azure-mgmt-kubernetesconfiguration 2.0.0
3
Answers
The problem is solved for me for the time being i.e. I am no more seeing the error.
What I did? --> Used VS Code rather than Pycharm IDE where I was getting error.
Workaround or solution? --> This is workaround. i.e. I could manage to make it working for me and proceed with my implementation.
So problem seems to be with Pycharm IDE and not sure what's the solution for it.
Any suggestions to solve this Pycharm problem is most welcome. (I will mark that answer as accepted, in that case.)
From the list i don’t see the package,
you need to do
You need to use the specific packages Starting with v5.0.0, in this case you need to install
here is the doc
I tried in my environment and got below results:
I installed package with
azure-container-service
with latest version by refering this document with my python version3.10.4
:Command:
After installed package in my environment and I tried the below code to get the list of pods it executed successfully.
Code:
Output:
Reference:
azure-samples-python-management/samples/containerservice at main · Azure-Samples/azure-samples-python-management · GitHub