简体   繁体   中英

How to deploy automatically Azure VMs and AKS on an environment?

I made a Terraform to create an infrastructure on Azure. I used the provider "microsoft/azuredevops".

I need to add VMs and Azure Kubernetes Service on a specific environment that I created. My question is how to deploy the script (which put tags) to them?

It's not possible to deploy it in an Azure DevOps Pipeline because this last doesn't know VMs (and AKS). I don't see anything else to made it with the provider azuredevops.

The solution (I think) will would be to extract the original script from an environment on Pipeline/Environment. I need to change all variables as personal access token and others too. But I don't know if Microsoft change the script regularly.

What's the best solution?

Thank you.

If you want to manage Azure resources with Terraform then you need to use the AzureRM provider not the Azure DevOps provider. The Azure DevOps provider is for managing your Azure DevOps instance.

The AzureRM provider contains resources for managing Linux and Windows VM's or for other types of resource such as AKS

Once you've written your terraform code, you can use a pipeline to run the terraform against Azure. Microsoft provide a terraform extension which can be used to call terraform in your pipeline

For the pipeline to be able to authenticate against Azure you'll need to set up a service connection . This will allow the pipeline to use a service principle in azure which can be given the appropriate level of permissions to create, update, destroy Azure Resources

Hashicorp have a good tutorial on getting started with Terraform and Azure and Microsoft also have some good documentation

Microsoft also have a tutorial on using Terraform from a pipeline, it uses the classic GUI based pipelines rather than YAML but the tasks and principles will be the same for both

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM