Package: ionosphere
ionosphereAboutIonosphere - library to createAzure Resource Manager
Templatesdescriptions (Ionosphere is porting of troposphere)The Ionosphere library allows for easier creation of the Azure Resource
Manager templates JSON by writing Python code to describe the Azure
resources.To facilitate catching ARM templates or JSON errors early the library
has property and type checking built into the classes.Currently supported Azure resource typesVirtual MachineVirtual Machine ExtensionVirtual Machine Scale SetsVirtual Machine Scale Set ExtensionVirtual NetworkPublic IP AddressNetwork InterfaceNetwork SecurityGroupApplication Security GroupLoad BalancerDns ZoneApplication GatewayStorage AccountExampleThe following example will generate an ARM Template that creates a VNet
and an Ubuntu VM with a public IP. The template also exposes port 22 on
the VM to the internet.# Create the objecttemplate=ARMTemplate()# Create VNET objectvnet=VirtualNetwork("myvnet",addressSpace=AddressSpace(addressPrefixes=['10.0.0.0/24']),subnets=[Subnet('main_subnet',addressPrefix='10.0.0.0/24')],tags={'key1':'tag-key1','key2':'tag-key2'})# Create Network Security Group object with "Allow SSH" rulensg=NetworkSecurityGroup("myNsg",securityRules=[SecurityRule('ssh',description='public ssh access',protocol='Tcp',destinationPortRange="22",destinationAddressPrefix="*",sourceAddressPrefix='Internet',sourcePortRange='*',access='Allow',direction='Inbound',priority=200)])# Create Public IP Address objectpublicIp=PublicIPAddress('my_vm_nic1_pubip',publicIPAllocationMethod='dynamic')# Create Network Interface objectnetworkInterface=NetworkInterface('myvm_nic1',ipConfigurations=[NetworkInterfaceIPConfiguration('my_vm_nic1_ip_config',privateIPAllocationMethod='Dynamic',subnet=SubResource(id=vnet.subnet_ref('main_subnet')),publicIPAddress=SubResource(id=publicIp.Ref()))],networkSecurityGroup=SubResource(id=nsg.Ref()))# Set dependencies on VNET & Public IP to the Network InterfacenetworkInterface.with_depends_on([publicIp,vnet])# Create a parameter for the VM password and add it to the templatevm_password_param=ARMParameter('vmPassword',template=template,type='secureString',description='The password for the VM access. User is "adminuser"')# Create the Virtual Machince objectvm=VirtualMachine('myvm',hardwareProfile=HardwareProfile(vmSize='Basic_A0'),storageProfile=StorageProfile(imageReference=ImageReference(publisher='Canonical',offer='UbuntuServer',sku='16.04-LTS'),osDisk=OsDisk(createOption='FromImage',diskSizeGB=50,managedDisk=ManagedDiskParameters(storageAccountType='Standard_LRS'))),osProfile=OSProfile(computerName='mytestvm',adminUsername='adminuser',adminPassword=vm_password_param.Ref(),linuxConfiguration=LinuxConfiguration(disablePasswordAuthentication=False)),networkProfile=NetworkProfile(networkInterfaces=[NetworkInterfaceReference(id=networkInterface.Ref())]))# Set dependency for the VM on the Network Interfacevm.with_depends_on(networkInterface)# Add all objects to the arm templatetemplate.add_resource([vnet,nsg,publicIp,networkInterface,vm])# Generate ARM Templateprint(template.to_json())ContributionsAll contributions are welcome.LicensingIonosphere is a fork of troposphere which is licensed under theBSD
2-Clause license. SeeLICENSEfor the Ionosphere full license text.