Hi,
Yes, there is a way to automate service principal connection. To automate service principal connections for ACR and AKS from Azure DevOps without manual intervention, you can use the Azure CLI task to create and manage service principals. First, create a Terraform project to create ACR and AKS resources. Then, in the Azure DevOps pipeline, add an Azure CLI task to create a service principal with the necessary permissions to access ACR and AKS. Finally, add a Terraform task to deploy the resources, which will use the service principal created in the previous step. This approach eliminates the need to manually create service connections for ACR and AKS in Azure DevOps. I once had this issue and searched for help. You can explore more at:
https://triotechsystems.com/azure-devops-service-principal-for-acr-and-aks/