© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page1 15
INFOBLOX API GUIDE FOR MICROSOFT AZURE
Infoblox API Guide - Managing Infoblox vNIOS for Microsoft Azure Appliances
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page2 15
Contents
Introduction....................................................................................................................................... 3
Prerequisites .................................................................................................................................... 3
Limitations ........................................................................................................................................ 3
Introduction to Scripting ................................................................................................................... 3
Infoblox Use Cases for Scripting with Microsoft Azure ....................................................... 3
Getting Started ................................................................................................................................. 4
Azure CLI ................................................................................................................................... 4
How to get it ........................................................................................................................ 4
How to use it ....................................................................................................................... 4
Additional Resources ..................................................................................................................... 10
Windows PowerShell ............................................................................................................... 11
PowerShell Basics ............................................................................................................ 11
PowerShell Applications.................................................................................................... 12
PowerShell Usage ............................................................................................................. 12
Command Examples ......................................................................................................... 13
Helpful Cmdlet Examples .................................................................................................. 14
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page3 15
Introduction
Infoblox vNIOS for Azure is a virtualized Infoblox appliance designed for deployment as a VM (virtual
machine) in Microsoft Azure, a collection of integrated cloud services in the Microsoft Cloud. Infoblox
vNIOS for Azure enables you to deploy robust, manageable, and cost effective Infoblox appliances in the
Microsoft Cloud. Infoblox NIOS is the underlying software running on Infoblox appliances and provides
core network services and a framework for integrating all the components of the modular Infoblox
solution. It provides integrated, secure, and easy-to-manage DNS (Domain Name System), IPAM (IP
address management) and other services.
Azure CLI is a command line based application which enables automation and command line based
management of Microsoft Azure services. The Azure CLI is also leveraged when managing Microsoft
Azure services via scripting (API), providing additional functions beyond what may be available through
the standard GUI based Azure web portal and automation of tasks through the use of scripts.
Windows PowerShell is a command line based shell with its own scripting language, commonly used by
system administrators and other users for automation of tasks, execution of advanced commands or for
performing administrative actions not available through the standard GUI based interfaces.
Prerequisites
The following are prerequisites for managing an Infoblox vNIOS for Azure appliance using scripting:
Valid login and subscription in Microsoft Azure.
Azure CLI 1.0
Appropriate permissions in Microsoft Azure to stop and start a VM instance.
Limitations
The Azure CLI is constantly evolving. At the time of this writing, version 2.0 of the Azure CLI is in preview
mode and the syntax for the commands referenced here, while minimal, will change. It can be expected
that any steps documented here can change at any time and without notice. Additionally, not all use
cases can be covered in this guide.
The example scripts provided in this guide use BASH, a Unix based shell. To be able to execute these
scripts using a Windows based computer, UnxUtils (Unix Utilities) may be required. For more information
regarding UnxUtils, refer to https://sourceforge.net/projects/unxutils/.
Introduction to Scripting
The use of scripting can be very useful when attempting to automate administrative tasks or execute
commands that may not be available through other means (such as through the Azure Portal). Azure
provides libraries through the Azure CLI which enable connectivity into the Azure cloud platform using a
variety of different platforms. This allows for highly flexible and customizable scripts to be used for
completing nearly any required task and using nearly any desired scripting language. These scripting
languages can include (but not limited to) bash (as demonstrated in this guide) and Python.
Infoblox Use Cases for Scripting with Microsoft Azure
The following are common use cases for using scrips to manage an Infoblox vNIOS for Azure VM:
a. You are deploying an Infoblox vNIOS for Azure appliance and require a configuration not
supported using the wizard in the Azure Portal (https://portal.azure.com/).
b. You need to automate the deployment, shutdown, restart or termination of an Infoblox vNIOS for
Azure appliance.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page4 15
The Custom Deployment Use Case In this use case, you must deploy an Infoblox vNIOS for Azure VM using parameters that may not be
configurable or allowed with the solution template that is called upon by the wizard when creating the VM
through the Azure Portal (https://portal.azure.com/).
The Automation Use Case For this use case, an administrator can automate the deployment, shutdown and restart or termination of
an Infoblox vNIOS for Azure appliance. This can be helpful in lab or QA environments where appliance
availability requirements can change rapidly and would allow for administrators to automate any changes
as required.
Getting Started
Azure CLI
For the examples provided in this guide to be able to function, the Azure CLI must first be installed. The
Azure CLI provides a simple command line interface to the Azure cloud, enabling administrators to
execute commands for operations which may not be available through the Azure web portal
(https://portal.azure.com/) and to automate many operations, helping to reduce both the administrator’s
workload and errors that can occur when commands are entered manually. The extensions added during
the installation of the Azure CLI are also leveraged for scripting access, such as by enabling the ability for
a scripting session to be able to authenticate with the Azure cloud platform and login to a subscription.
In this guide, examples for creating an Infoblox vNIOS for Azure VM through the API are provided. These
script examples are written as BASH shell scripts, a language common to Linux based operating systems.
For Windows based computers, additional supporting software or steps may be required.
How to get it
The Azure CLI is available for both Windows and Linux based operating systems. Instructions and
download information the supported platforms can be found at https://docs.microsoft.com/en-
us/azure/xplat-cli-install/.
How to use it
The installation of the Azure CLI adds libraries to your computer which are executed through either a
terminal window for *nix based computers or through a command prompt for Windows based computers.
To run commands in Azure, each command is prefixed with the command “azure”.
Example:
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page5 15
Scripting Basics
Bash
Bash (Bourne-Again Shell), as its full name implies and its corresponding scripting language, is a ‘shell’
program used by default on Linux based computers (including Apple OS X). Bash is a powerful shell,
providing a vast array of features and capabilities, from very simple operations to complex commands
and scripts. In this guide, example scripts which written using bash are provided and these can be
executed from any computer which supports the bash shell and have all required dependencies installed.
Many of these dependencies are frequently met with default installations, though this will vary from
computer to computer depending on how the operating system was installed. Refer to the reference
URL’s provided earlier in this guide for more details regarding this.
JSON
JSON (JavaScript Object Notation) provides a specification used for the formatting of text in a format that
is easy for both humans and computers to read and write. In Azure, the output of properties from many
different commands is returned in JSON format and Infoblox also uses the JSON format for the parameter
files (templates) used during the creation of Infoblox vNIOS for Azure VM’s.
Script Structure
A Script used to create an Infoblox vNIOS for Azure VM consists of two pieces:
The script which sets the dynamic values that are going to be applied
The JSON formatted parameters file which sets up the configuration on the VM and the
environment that it is being deployed in.
In the script, you can control whether a new Resource Group is created or not and the name to be used
for the Resource Group. The name for the VM, network configuration and other options being enabled are
set in the parameters file.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page6 15
Script Examples
In the following script example, you can see a working demonstration where a Resource Group and
Virtual Machine is created. This is followed with the parameters file, where the vNet (Virtual Network),
network interfaces, public IP address (PIP) and Availability Zone (AZ) are configured.
Before your script can be executed, your session must be authenticated. This can be done every time the
script executes by including the following line in the script:
azure login
Otherwise, simply run the command “azure login” through the CLI prior to running your script.
Once your session has been successfully authenticated, you can continue to run your script. Here is a
working example that will leverage the referenced .json parameters file and create a new Resource
Group, along with an Infoblox vNIOS for Azure VM and assign it a public IP address and Availability
Zone:
AZURE_TEMPLATE_URI=https://raw.githubusercontent.com/infobloxopen/infoblox-azure-
templates/master/main/mainTemplate.json
PARAMETERS_DIR="utils/params"
PREFIX="ext1-"
DEPLOYMENT_NAME="${PREFIX}deployment$(date +%Y%m%d%H%M%S)"
RESOURCE_GROUP="${PREFIX}group"
LOCATION="eastus"
azure group create "${RESOURCE_GROUP}" "${LOCATION}"
if azure group show ${RESOURCE_GROUP} &> /dev/null; then
echo -e "\nSuccess! Resource group '${RESOURCE_GROUP}' exists.\n"
fi
echo "-------------------"
echo -e "Creating Infoblox vNIOS for Azure appliance (Model VNIOS-TE-V1420).\nWhen
prompted, enter the value for machine size to be used.\nThe supported values are:
Standard_DS2, Standard_DS2_v2, Standard_DS3, or Standard_DS3_v2\n"
azure group deployment create \
--template-uri "${AZURE_TEMPLATE_URI}" \
--parameters-file "${PARAMETERS_DIR}/parameters.allnew.json" \
--resource-group "${RESOURCE_GROUP}" \
"${DEPLOYMENT_NAME}"
echo "-------------------"
In the above example, the values highlighted in green can be updated to reflect the names or values that
you want to use when the corresponding objects are created in Azure. This includes the directory where
the parameters file is located, the prefix that will be used when objects specified in the script are created,
name to be used for the Resource Group (appended with the prefix label), the location and the name of
the parameters file.
JSON Template
To support the script, a JSON formatted parameters file must also be used. The following table lists the
supported parameters and allowed values that are used in the parameters file:
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page7 15
Parameter Description Allowed Values
baseURL URL for the main parameters
template
Location Default location for resources
vmName Name for the Virtual Machine
niosModel vNIOS for Azure VM type "vnios-te-v820", "vnios-te-v1420",
"vnios-te-v2220", "vnios-cp-v800",
"vnios-cp-v1400", "vnios-cp-
v2200". Default= vnios-te-v1420
niosVersion NIOS version “latest”, or other supported version
adminPassword Password for admin account
virtualNetworkName Name for vNet
virtualNetworkExistingRGName Resource Group for vNet
virtualNetworkAddressPrefix vNet address and CIDR
vnetNewOrExisting Use a new or existing vNet "new", "existing". Default= new Subnet1Name Subnet name for LAN1
Subnet1Prefix Subnet address and CIDR
Subnet1StartAddress Sets first available IP
Subnet2Name Subnet name for MGMT
Subnet2Prefix Subnet address and CIDR
Subnet2StartAddress Sets first available IP
newStorageAccountName Name for storage account used
for the VM’s disks
storageAccountType Sets the storage account type Premium_LRS
storageAccountNewOrExisting Use a new or existing storage
account
“new”, “existing”
storageAccountExistingRG Name of Resource Group for
storage account
newstorageAccountForLogsName Name for storage account used
for boot diagnostics
storageAccountForLogsType Sets the boot diagnostics
storage account type
Standard_LRS
storageAccountForLogsNewOrExisting Create a new or use an existing
boot diagnostics storage
account
"new", "existing". Default= new
storageAccountForLogsExistingRG Name of Resource Group for
boot diagnostics storage
account
publicIPAddressName Name for public IP object
publicIPDnsName DNS name for public IP
publicIPNewOrExistingOrNone Create a new, assign an
existing, or do not use a public
IP address
"new", "existing", "none". Default= none
publicIPExistingRGName Name of Resource Group for
public IP address
availabilitySetNewOrExistingOrNone Create a new, assign an
existing, or do not use an
Availability Set
"new", "existing", "none". Default= none
availabilitySetName Name for Availability Set if
being used
customData Refer to Azure Install Guide
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page8 15
The following example demonstrates a working JSON formatted template file:
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"baseUrl": {
"value": "https://raw.githubusercontent.com/infobloxopen/infoblox-azure-templates/master/main/"
},
"vmName": {
"value": "test1vmallnew"
},
"niosModel": {
"value": "vnios-te-v1420"
},
"niosVersion": {
"value": "latest"
},
"adminPassword": {
"value": "Infoblox=111"
},
"virtualNetworkName": {
"value": "vnet01"
},
"virtualNetworkExistingRGName": {
"value": "test1group"
},
"virtualNetworkAddressPrefix": {
"value": "10.4.0.0/16"
},
"vnetNewOrExisting": {
"value": "new"
},
"subnet1Prefix": {
"value": "10.4.0.0/24"
},
"subnet1Name": {
"value": "subnet1"
},
"subnet1StartAddress": {
"value": "10.4.0.4"
},
"subnet2Prefix": {
"value": "10.4.1.0/24"
},
"subnet2Name": {
"value": "subnet2"
},
"subnet2StartAddress": {
"value": "10.4.1.4"
},
"newStorageAccountName": {
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page9 15
"value": "test1group"
},
"storageAccountType": {
"value": "Premium_LRS"
},
"storageAccountNewOrExisting": {
"value": "new"
},
"storageAccountExistingRG": {
"value": "test1group"
},
"newStorageAccountForLogsName": {
"value": "test1grouplogs"
},
"storageAccountForLogsType": {
"value": "Standard_LRS"
},
"storageAccountForLogsNewOrExisting": {
"value": "new"
},
"storageAccountForLogsExistingRG": {
"value": "test1group"
},
"publicIPAddressName": {
"value": "test1pip"
},
"publicIPDnsName": {
"value": "test1pip"
},
"publicIPNewOrExistingOrNone": {
"value": "new"
},
"publicIPExistingRGName": {
"value": "test1group"
},
"availabilitySetNewOrExistingOrNone": {
"value": "new"
},
"availabilitySetName": {
"value": "someset"
},
"customData": {
"value": "#infoblox-config\nremote_console_enabled: y\ndefault_admin_password:
yanmlpasswd\ntemp_license: cloud vnios dns"
}
}
}
In the above example, the values listed can be used as is as long as no conflict occurs. In case of conflict
or preference, replace the values marked in bold and the color green with the values you want to use for
your deployment. Note: The template file for a can also be downloaded from the Summary screen when
launching an Infoblox VM through the Azure Marketplace.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page10 15
Creating the Infoblox vNIOS for Azure VM
When running the script such as the example provided here, there is a single prompt where you must
specify the model to be used for the Infoblox vNIOS for Azure VM and allowed values are displayed on
the screen prior to this prompt. To execute the script, be sure that the examples have been saved to a file
on the computer where you will be running them from. The script should use a .sh extension and be
called using bash or other compatible program, while the parameters file should use a .json extension. Be
sure that parameters file is also located in the correct directory (update the path for this in the script file as
required).
Once ready to run the script, you would call it by entering the command “bash”, followed by the file name
used for the file the script was saved to. The following screenshot demonstrates how this will appear:
As the script runs, the status for each completed step will be displayed and assuming no errors are
encountered, a final summary will be displayed once the enter script finishes:
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page11 15
Additional Resources
Windows PowerShell
Windows PowerShell, also referred to as Microsoft PowerShell or just PowerShell, provides a scripting
shell which can be used to automate tasks an administrator may need to complete when managing an
Infoblox vNIOS for Azure appliance. Commands executed in PowerShell are referred to as cmdlets and
the names of which are generally structured with a verb
followed by the command name. Example: Get-Help
PowerShell is built on Microsoft .NET framework and
allows you to call .NET classes and methods directly
from your PowerShell console. Cmdlets provide
shortcuts to the .Net classes and would return the
corresponding .NET object. As an example, executing
the cmdlet Get-Date would return the
System.DateTime .NET object, showing that executing
the Get-Date cmdlet is equivalent to executing
[System.DateTime]::Now command, both of which
can be run in the PowerShell console and would return
the same results.
PowerShell Basics
Before implementing Infoblox vNIOS for Azure, an administrator must understand common terms or
objects available in Azure related to the implementation of vNIOS. The following are common objects and
terms:
PowerShell Framework: PowerShell uses the .NET Framework common language runtime and the .NET
Framework. When running commands, PowerShell values and variables are always sent and received as
objects. This is contrary to most other scripting shells which are text based.
Cmdlet: The commands which run in PowerShell. Core/base cmdlets are included in PowerShell. Custom
cmdlets are also supported and can be added using snap-ins. Multiple cmdlets can be run in a single
command.
Providers: PowerShell gives you access to your computers file system by default. A provider enables
access to other data stores, including the Windows Registry.
Snap-in: A Microsoft .NET Framework assembly which holds providers and/or cmdlets.
Class: A segment of code structured into a usable command that can be called upon in a program. These
can be used to make a cmdlet.
Namespace: A collection of Classes that are grouped together.
Object: When running a command, PowerShell builds objects for each result which holds any data
returned. This would be similar to an array for those familiar with other programming languages.
Variable: Used to assign a name for any object or property being sent or received in a command.
PowerShell is object oriented so any output from a command is returned in an object. Common practice is
to first assign a variable to the object that will result from your command and then call that variable to be
able to view the results. The objects are stored in memory for your current PowerShell session and can
be referenced repeatedly as needed.
Function: Similar to a class, a function creates a command that can be called upon in other commands
or directly in the console during your current PowerShell session.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page12 15
Intellisense: Included in some PowerShell windows (such as the script pane in ISE). As you type a
command, a drop-down menu of available options will be displayed and filters the results as you type.
This provides a way to auto-complete commands and to verify options that might be supported for the
command you are executing.
PowerShell Applications
PowerShell commands are run in the PowerShell Command Prompt. The Windows PowerShell ISE
(Integrated Scripting Environment) application includes both the Command Prompt (Console), along with
a script pane and an add-on displaying a list of available commands. The Command Prompt is a simple
interface which operates the same way as a traditional Windows command prompt, allowing you to run
commands:
PowerShell ISE is a much more robust application and is frequently used for script development or even
for just an easy to use interface:
PowerShell Usage
PowerShell provides a vast library of cmdlets already built-in. To manage your Infoblox vNIOS for Azure
appliances, you can leverage any number of these cmdlets, or even create your own in order to fit your
needs. In this guide, we provide samples demonstrating commands that may be useful for administrators
just starting out with Microsoft Azure and who wish to manage some of their VM’s (including Infoblox
vNIOS for Azure appliances) using PowerShell.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page13 15
Start-AzureRmVM -Name "virtual-machine-name" -ResourceGroupName "resource-group-name"
Get-AzureRmSubscription | select SubscriptionId, State
Get-AzureRmSubscription
Login-AzureRmAccount
Select-AzureSubscription -SubscriptionName "your-subscription-name-here"
Command Examples
The script samples provided here are intended to allow an administrator to restart, shutdown, or terminate
an Infoblox vNIOS for Azure appliance using PowerShell. These are not Infoblox specific scripts and can
be applied to any Virtual Machine operating in the Microsoft Azure cloud platform. As PowerShell is a
constantly evolving environment, these examples are subject to change without notice and are provided
without any warranty.
Initial Connection Prior to running any cmdlets to manage your Infoblox vNIOS for Azure appliance, you will first need to
login to Azure and connect to your Subscription. To login to Azure:
Follow the prompts to complete the login process.
To verify your Subscription details:
Note: For easier to read output, you can include an additional cmdlet to limit the results so that you only
see the Subscription name and ID:
If you have multiple Subscriptions available and need to change the selected Subscription:
Restart an Infoblox vNIOS for Azure appliance Once logged in and connected to the Subscription that your Infoblox vNIOS for Azure appliance resides
in, you can use the following example to restart it:
Restart-AzureRmVM -Name "virtual-machine-name" -ResourceGroupName "resource-group-name"
Note: In the above example, replace the strings encapsulated in quotation marks with the correct values
(the names for both your VM and Resource Group).
Shutdown an Infoblox vNIOS for Azure Appliance There may be cases where you wish to be able to shut down a VM, such as if it is used for testing
purposes and you do not wish to leave it running while it is not being used. To shut down the VM, use the
following example:
Stop-AzureRmVM -Name "virtual-machine-name" -ResourceGroupName "resource-group-name"
Note: In the above example, replace the strings encapsulated in quotation marks with the correct values
(the names for both your VM and Resource Group).
Start an Infoblox vNIOS for Azure Appliance If a VM has been shut down, you can start it by using the following example:
Note: In the above example, replace the strings encapsulated in quotation marks with the correct values
(the names for your VM and Resource Group).
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page14 15
### Do NOT modify this code. This is to be executed as a single
command.
function Get-AzureRmVMPowerStatus {
[CmdletBinding()]
param (
#The name of the resource group your VM's are found in
[Parameter(Mandatory=$true)]
[string]
$ResourceGroupName
,
# Filter for VM names
[Parameter()]
[string]
$Name = '*'
)
Get-AzureRmVM -ResourceGroupName $ResourceGroupName |
Get-AzureRmVM -Status |
Select-Object -Property Name, Statuses |
Where-Object {$_.Name -like $Name} |
ForEach-Object {
$VMName = $_.Name
$_.Statuses |
Where-Object {$_.Code -like 'PowerState/*'} |
ForEach-Object {
New-Object -TypeName psobject -Property @{
Name = $VMName
Status = $_.DisplayStatus
} } } }
#### Do NOT modify the code provided in this example.
Helpful Cmdlet Examples
Resource Groups Get a listing of available Resource Group names and their locations:
Get-AzureRmResourceGroup | select ResourceGroupName, Location
Example:
PS C:\scripts> Get-AzureRmResourceGroup | select ResourceGroupName, Location
WARNING: The output object type of this cmdlet will be modified in a future release.
ResourceGroupName Location
----------------- --------
resourcegroup1 westus
resourcegroup2 westus
Virtual Machine Status You can also get the current status for all VM’s in a specific Resource Group using PowerShell. To do
this, you must first create a function. A function is essentially a cmdlet that can be used in your current
PowerShell session. With a function, you create it first and then execute it in a subsequent command,
calling the name that you specified when you created it and any parameters that you must enter would be
entered at that point.
© 2017 Infoblox Inc. All rights reserved. Infoblox API Guide – Managing Infoblox vNIOS for Microsoft Azure March 2017 Page15 15
Once the Get-AzureRmVMPowerStatus function has been created, the following example demonstrates
the syntax to list the status for all VM’s in the specified Resource Group:
Get-AzureRmVMPowerStatus -ResourceGroupName "your-resource-group-name-here"
Note: In the above example, replace the string in between the quotation marks with the name for your
Resource Group. Examples:
PS C:\scripts> Get-AzureRmVMPowerStatus -ResourceGroupName "resourcegroup1"
Name Status
---- ------
azure-vm1 VM running
azure-vm2 VM stopped
PS C:\scripts> Get-AzureRmVMPowerStatus -ResourceGroupName "resourcegroup2"
Name Status
---- ------
azure-vm3 VM deallocated