Many thanks for your help. Now I'm stuck with the creation of the aks cluster. Stupidly the error message is not very helpful.
containerservice_client.managed_clusters.begin_create_or_update(RESOURCE_GROUP_NAME, K8S_CLUSTER_NAME, parameters)
File "/usr/local/lib/python3.9/site-packages/azure/mgmt/containerservice/v2021_07_01/operations/_managed_clusters_operations.py", line 736, in begin_create_or_update
raw_result = self._create_or_update_initial(
File "/usr/local/lib/python3.9/site-packages/azure/mgmt/containerservice/v2021_07_01/operations/_managed_clusters_operations.py", line 678, in _create_or_update_initial
body_content = self._serialize.body(parameters, 'ManagedCluster')
File "/usr/local/lib/python3.9/site-packages/msrest/serialization.py", line 626, in body
errors = _recursive_validate(data_type, data_type, data)
File "/usr/local/lib/python3.9/site-packages/msrest/serialization.py", line 160, in _recursive_validate
return data.validate()
File "/usr/local/lib/python3.9/site-packages/msrest/serialization.py", line 254, in validate
validation_result += _recursive_validate(attr_name, attr_type, value)
File "/usr/local/lib/python3.9/site-packages/msrest/serialization.py", line 152, in _recursive_validate
for content in data:
TypeError: 'ManagedClusterAgentPoolProfile' object is not iterable
Process finished with exit code 1
# Obtain the management object for resources.
resource_client = ResourceManagementClient(credential, SUBSCRIPTION_ID)
# Provision the resource group
rg_result = resource_client.resource_groups.create_or_update(
RESOURCE_GROUP_NAME,
{
"location": LOCATION,
"tags": {"environment": "test", "department": "tech"}
})
logging.getLogger("main").info(f"Provisioned resource group {rg_result.name} in the {rg_result.location} region")
for app in get_client_from_cli_profile(GraphRbacManagementClient).applications.list(filter="displayName eq 'RTTS ICE AKS Cluster'"):
get_client_from_cli_profile(GraphRbacManagementClient).applications.delete(app.object_id)
app = get_client_from_cli_profile(GraphRbacManagementClient).applications.create({
'available_to_other_tenants': False,
'display_name': 'RTTS ICE AKS Cluster',
'identifier_uris': ['http://test123.org/']
})
logging.getLogger("main").info(f"Provisioned application app.display_name with id {app.app_id}")
# create aks cluster service principal. Use get_client_from_cli_profile for legacy library here
sp_params = azure.graphrbac.models.ServicePrincipalCreateParameters(app_id=app.app_id, app_role_assignment_required=False, account_enabled=True)
sp_result = get_client_from_cli_profile(GraphRbacManagementClient).service_principals.create(sp_params)
logging.getLogger("main").info(f"Provisioned service principal {sp_result.object_id}")
containerservice_client = ContainerServiceClient(credential, SUBSCRIPTION_ID)
parameters = ManagedCluster(
location=LOCATION,
kubernetes_version="1.19.1",
enable_rbac=True,
service_principal_profile=ManagedClusterServicePrincipalProfile(client_id=sp_result.object_id),
agent_pool_profiles=ManagedClusterAgentPoolProfile(name=K8S_CLUSTER_NAME,
vm_size='Standard_E2ds_v4',
count=1,
min_count=1,
max_count=30,
enable_auto_scaling=True)
)
containerservice_client.managed_clusters.begin_create_or_update(RESOURCE_GROUP_NAME, K8S_CLUSTER_NAME, parameters)
# Optional lines to delete the resource group. begin_delete is asynchronous.
poller = resource_client.resource_groups.begin_delete(rg_result.name)
result = poller.result()