-
Notifications
You must be signed in to change notification settings - Fork 2
Basic Example
This simple example will just spin-up one VM. For more examples, please see the examples folder in the repo.
The first thing you will need is a template file, which will look as follows:
{
"template": [
{
"tag": "test",
"type": "vm",
"count": 1,
"os": {
"type": "Windows",
"size": "Standard_DS1_v2",
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"skus": "2016-Datacenter"
},
"usePublicIP": true
}
]
}The above template will be used by Fogg to deploy one public Windows 2016 VM. You will notice the count value, changing this to 2, 3 or more will deploy 2, 3 or more of this VM type. (Note, if you deploy a VM type with a count > 1, Fogg will automatically load balance your VMs for you, this can be disabled via: "useLoadBalancer": false, though you will still get an availability set).
The tag and type values for template objects are mandatory. the tag can be any unique alphanumeric string (though try and keep it short). The type value can only be one of either "vm" or "vpn".
To use Fogg and the template file above, you will need an Azure Subscription. In general, the call to Fogg would look as follows:
fogg -SubscriptionName "AzureSub" -ResourceGroupName "basic-rg" -Location "westeurope" -VNetAddress "10.1.0.0/16" -SubnetAddresses @{"vm"="10.1.0.0/24"} -TemplatePath "<path_to_above_template>"This will tell Fogg to use the above template against your Subscription in Azure. Fogg will then:
- Validate the template file
- Request for you Azure Subscription credentials
- Request for administrator credentials to deploy the VMs
- Create a Resource Group called
basic-rgin Locationwesteurope - Create a Storage Account called
basicstdsa(orbasic-std-safor Standard Storage) - Create a Virtual Network called
basic-vnetfor address10.1.0.0/16 - Create a Network Security Group (
basic-vm1-nsg) and Subnet (basic-vm1-snet) for address10.1.0.0/24 - Create an Availability Set called
basic-vm-as - Create a Network Interface Card called
basic-vm1-nic - Create a Public IP address called
basic-vm1-pip, and assign it to the NIC - A Virtual Machine called
basic-vm1will then be deployed under thebasic-vm1-snetSubnet
To create a Foggfile of the above, stored at the root of the repo (can be else where as a -FoggfilePath can be supplied), would look like the folllowing:
{
"Groups": [
{
"ResourceGroupName": "basic-rg",
"Location": "westeurope",
"TemplatePath": "<path_to_above_template>",
"VNetAddress": "10.1.0.0/16",
"SubnetAddresses": {
"vm": "10.1.0.0/24"
}
}
]
}Note that the above leaves out the SubscriptionName, this is because the Foggfile at the root of a repo will mostly be used by your devs/QAs/etc to spin-up the infrastructure in their MSDN Azure subscriptions. If the subscription name is the same for all, then you could add in the "SubscriptionName": "<name>" to the Foggfile (as a part of the main JSON object, not within the Groups objects); if left out Fogg will request it when called.
Also note that if the path used for the TemplatePath is relative, it must be relative to the Foggfile's location.
If you are using a Foggfile at the root, then the call to use Fogg would simply be:
foggIf you pass in the parameters on the CLI while using a Foggfile, the parameters from the CLI have higher precidence and will override the Foggfile's values. (ie: passing -SubscriptionName will override the "SubscriptionName" in the Foggfile)