Automate VM deployment in Azure using Azure Rest API RRS feed

  • Question

  • Hi Everyone,

    I need to automate VM deployment in Azure using Rest API. Azure Powershell and CLI are not an option in my project. I won't be using a client application for the same, all the rest API calls needs to be made via coding (preferably python). 

    I need to know how can this be achieved. I have already been through the Microsoft documentation on the same but couldn't hit the correct resolution for my queries.

    I will require solution to below points.

    • Authentication using Azure Rest API calls via code.
    • Deployment steps of a resource through Azure Rest API calls from a code.
    • Whether keeping the deployment code as an Azure function would work on not
    • All the permissions that need to be set in Azure for the deployment
    • Prerequisite and how can they be setup to perform the actions

    Note : I am new to Azure and hence don't have much knowledge even of a beginner.  

    Thanks in advance for any and all the help.

    Sunday, September 22, 2019 8:40 AM

All replies

  • Hello Abhilash,

    For your ask on how to automate VM deployment in Azure using python SDK, below are the suggestions for your queries.

    • To get started/prerequisites would be to create a Resource Group where you want to deploy the VM's. Go through this document that guides you with the steps.
    • Next is to create a service principal and assign it a contributor access on the previously created Resource Group, so that when the SP is used in code it has appropriate permissions on the RG.
    • For Authentication, please check this document.
    • Yes, you can have the deployment code as Azure Function if you want to go with a serverless architecture, refer this tutorial for creating a Python function.
    • Refer this python sample for managing Azure VM with python.

    Please let me know if you still need any other information on this.

    If the suggestions provided answers your queries, do click on "Mark as Answer" and "Up-Vote" on the answer that helped you so that it will be beneficial to other community members.


    Monday, September 23, 2019 10:26 AM
  • Hi Vikas, As you mentioned a Resource Group is a prerequisite, I would be implementing this on an enterprise level, which bounds to have more than one resource group. Hence, whether the contributor access needs to be provided to all the resource groups for the service principal for deploying VM in a specific resource group as per the requirement?
    Tuesday, September 24, 2019 3:44 PM
  • Hello Abhilash,

    Apologies in delayed response. Yes, you need to get access for all the resource groups where you want to deploy the VM's through your automation.

    To make it more simpler(instead of resource group level), you can get the contributor access on the subscription level to the service principal (if this is allowed in the enterprise).


    Thursday, September 26, 2019 7:02 AM

  • Hello Abhilash,

    Any update on this issue?

    If the above helped please remember to "Up-vote" and "Mark as Answer" so others in the community can benefit.


    Monday, September 30, 2019 9:23 AM
  • Hello Abhilash,

    Any update on the issue?

    Just checking in if you got a chance to see my previous reply.

    If the suggested answer has solved your query, do click on "Mark as Answer" and "Up-Vote" for the benefit of other community members.


    Thursday, October 3, 2019 5:44 AM