0

Currently we use boto (python library) to deploy infrastructure as code using AWS services. In my current project I am trying to create infrastructure as code for Azure, but I would like to stick with python to generate this code.

do we have any python libraries to invoke Azure APIs to setup infrastructure. or create json templates to deploy on azure.

3 Answers 3

4

There is a python SDK (in preview) that allows to work with Azure Resource Manager to create resource groups, VMs...

You'll find the documentation here : http://azure-sdk-for-python.readthedocs.org/en/latest/resourcemanagement.html

The SDK is hosted on GitHub : https://github.com/azure/azure-sdk-for-python

Another solution could be to use Azure Resource Management REST APIs directly. These APIs are documented here: https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx

Hope this helps

Julien

Sign up to request clarification or add additional context in comments.

2 Comments

Julien, thanks for your help, however I would like to create custom templates to deploy on Azure. I have seen many examples of the pre-built json templates that people deploy on azure to stand up custom infrastructure. is there is way we can develop our own template. Example: Following link has json based template that I can deploy, however I want to create my own template msdn.microsoft.com/en-us/library/azure/dn790564.aspx
Anup, I don't have heard about any tool that allows to generate directly the JSON ARM template with Python, but there is a tool available with Visual Studio and the Azure tools : visualstudio.com/en-us/features/azure-tools-vs.aspx. Another way is to start from an existing quickstart template available on GitHub and modify one to make it fit your needs : github.com/Azure/azure-quickstart-templates
0

About how to create custom templates for Azure resource management, you can refer to the document https://azure.microsoft.com/en-us/documentation/articles/resource-group-authoring-templates/ to know the template structure & format.

The basic structure of a template as below:

{
   "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
   "contentVersion": "",
   "parameters": { ... },
   "variables": { ... },
   "resources": [ ... ],
   "outputs": { ... }
}

And you can access the schema url of deployment template (https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json) to get the metadata definition of template.

Comments

0

If anyone stumbles over this in 2023 then I would suggest Pulumi as a cross language and cross platform IaC (Infrastructure as Code) tool. I have used it myself to write in C# and Python. https://www.pulumi.com/docs/get-started/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.