lib/fog/azurerm/docs/compute.md in fog-azure-rm-0.3.7 vs lib/fog/azurerm/docs/compute.md in fog-azure-rm-0.3.8
- old
+ new
@@ -1,8 +1,8 @@
# Compute
-This document explains how to get started using Azure Compute Service with Fog. With this gem you can create/update/list/delete availability sets and virtual machines.
+This document explains how to get started using Azure Compute Service with Fog. With this gem you can create, update, list or delete availability sets and virtual machines.
## Usage
First of all, you need to require the Fog library by executing:
@@ -13,111 +13,115 @@
## Create Connection
Next, create a connection to the Compute Service:
```ruby
- azure_compute_service = Fog::Compute::AzureRM.new(
- tenant_id: '<Tenantid>', # Tenant id of Azure Active Directory Application
- client_id: '<Clientid>', # Client id of Azure Active Directory Application
- client_secret: '<ClientSecret>', # Client Secret of Azure Active Directory Application
- subscription_id: '<Subscriptionid>', # Subscription id of an Azure Account
- environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
+fog_compute_service = Fog::Compute::AzureRM.new(
+ tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
+ client_id: '<Client Id>', # Client Id of Azure Active Directory Application
+ client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
+ subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
+ environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
)
```
## Check Server Existence
```ruby
-azure_compute_service.servers.check_vm_exists(<Resource Group name>, <VM Name>)
+fog_compute_service.servers.check_vm_exists('<Resource Group Name>', '<VM Name>')
```
## Create Server
**Info:**
-- Attribute **network_interface_card_ids** is an array of NICs ids. The NIC id at index zero will become primary NIC of this server(virtual machine) by default.
+- Attribute **network_interface_card_ids** is an array of NICs Ids. The NIC Id at index zero will become primary NIC of this server (virtual machine) by default.
- To create VM with managed OS disk, use the _managed_disk_storage_type_ argument
- To create VM with unmanaged OS disk, use the _storage_account_name_ argument
+
### Virtual Machine (Managed OS Disk)
```ruby
- azure_compute_service.servers.create(
+fog_compute_service.servers.create(
name: '<VM Name>',
- location: 'West US',
+ location: '<Location>',
resource_group: '<Resource Group Name>',
- vm_size: 'Basic_A0',
- username: '<Username for VM>',
- password: '<Password for VM>', # Optional, if 'platform' partameter is 'Linux'.
- disable_password_authentication: false,
- network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
- availability_set_id: '<availability_set_id>', # Optional
- publisher: 'Canonical', # Not required if custom image is being used
- offer: 'UbuntuServer', # Not required if custom image is being used
- sku: '14.04.2-LTS', # Not required if custom image is being used
- version: 'latest', # Not required if custom image is being used
- platform: 'Linux',
- vhd_path: '<Path of VHD>', # Optional, if you want to create the VM from a custom image.
- custom_data: 'echo customData', # Optional, if you want to add custom data in this VM.
- os_disk_caching: Fog::ARM::Compute::Models::CachingTypes::None, # Optional, can be one of None, ReadOnly, ReadWrite
- managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS, # Optional if storage_account_name is passed, can be StandardLRS or PremiumLRS
- os_disk_size: <Disk Size> # Optional, size of the os disk in GB (upto 1023)
- )
+ tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' },
+ vm_size: '<Virtual Machine Size>',
+ username: '<Username>',
+ disable_password_authentication: <True/False>,
+ network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
+ publisher: '<Publisher Name>', # Not required if custom image is being used
+ offer: '<Offer Name>', # Not required if custom image is being used
+ sku: '<SKU Name>', # Not required if custom image is being used
+ version: '<Version>', # Not required if custom image is being used
+ platform: '<OS Type>',
+ availability_set_id: '<Availability Set Id>', # [Optional]
+ password: '<Password>', # [Optional], if 'platform' partameter is 'Linux'.
+ vhd_path: '<Path of VHD>', # [Optional], if you want to create the VM from a custom image.
+ custom_data: '<Custom Data Value>', # [Optional], if you want to add custom data in this VM.
+ os_disk_caching: '<Caching Type>', # [Optional], can be one of None, ReadOnly, ReadWrite
+ managed_disk_storage_type: '<Storage Account Type>', # [Optional], if storage_account_name is passed, can be StandardLRS or PremiumLRS
+ os_disk_size: <Disk Size> # [Optional], size of the os disk in GB (upto 1023)
+)
```
### Virtual Machine (Unmanaged OS Disk)
```ruby
- azure_compute_service.servers.create(
+fog_compute_service.servers.create(
name: '<VM Name>',
- location: 'West US',
+ location: '<Location>',
resource_group: '<Resource Group Name>',
- vm_size: 'Basic_A0',
+ tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' },
+ vm_size: '<Virtual Machine Size>',
storage_account_name: '<Storage Account Name>',
- username: '<Username for VM>',
- password: '<Password for VM>',
- disable_password_authentication: false,
- network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
- availability_set_id: '<availability_set_id>', # Optional
- publisher: 'MicrosoftWindowsServerEssentials', # Not required if custom image is being used
- offer: 'WindowsServerEssentials', # Not required if custom image is being used
- sku: 'WindowsServerEssentials', # Not required if custom image is being used
- version: 'latest', # Not required if custom image is being used
- platform: 'Windows',
- vhd_path: '<Path of VHD>', # Optional, if you want to create the VM from a custom image.
- custom_data: 'echo customData', # Optional, if you want to add custom data in this VM.
- os_disk_size: <Disk Size> # Optional, size of the os disk in GB (upto 1023)
- )
+ username: '<Username>',
+ password: '<Password>',
+ disable_password_authentication: <True/False>,
+ network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
+ publisher: '<Publisher Name>', # Not required if custom image is being used
+ offer: '<Offer Name>', # Not required if custom image is being used
+ sku: '<SKU Name>', # Not required if custom image is being used
+ version: '<Version>', # Not required if custom image is being used
+ platform: '<OS Type>',
+ availability_set_id: '<Availability Set Id>', # [Optional]
+ vhd_path: '<Path of VHD>', # [Optional], if you want to create the VM from a custom image.
+ custom_data: '<Custom Data Value>', # [Optional], if you want to add custom data in this VM.
+ os_disk_size: <Disk Size> # [Optional], size of the os disk in GB (upto 1023)
+)
```
## Create Server Asynchronously
Create a new linux server asynchronously
```ruby
- async_response = azure_compute_service.servers.create_async(
+async_response = fog_compute_service.servers.create_async(
name: '<VM Name>',
- location: 'West US',
+ location: '<Location>',
resource_group: '<Resource Group Name>',
- vm_size: 'Basic_A0',
+ tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' },
+ vm_size: '<Virtual Machine Size>',
storage_account_name: '<Storage Account Name>',
username: '<Username for VM>',
- password: '<Password for VM>', # Optional, if 'platform' partameter is 'Linux'.
- disable_password_authentication: false,
- network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
- availability_set_id: '<availability_set_id>', # Optional
- publisher: 'Canonical', # Not required if custom image is being used
- offer: 'UbuntuServer', # Not required if custom image is being used
- sku: '14.04.2-LTS', # Not required if custom image is being used
- version: 'latest', # Not required if custom image is being used
- platform: 'Linux',
- vhd_path: '<Path of VHD>', # Optional, if you want to create the VM from a custom image.
- custom_data: 'echo customData', # Optional, if you want to add custom data in this VM.
- os_disk_caching: Fog::ARM::Compute::Models::CachingTypes::None, # Optional, can be one of None, ReadOnly, ReadWrite
- managed_disk_storage_type: Azure::ARM::Compute::Models::StorageAccountTypes::StandardLRS, # Optional, can be StandardLRS or PremiumLRS
- os_disk_size: <Disk Size> # Optional, size of the os disk in GB (upto 1023)
- )
+ disable_password_authentication: <True/False>,
+ network_interface_card_ids: ['/subscriptions/<Subscription Id>/resourceGroups/<Resource Group Name>/providers/Microsoft.Network/networkInterfaces/<Network Interface Id>'],
+ publisher: '<Publisher Name>', # Not required if custom image is being used
+ offer: '<Offer Name>', # Not required if custom image is being used
+ sku: '<SKU Name>', # Not required if custom image is being used
+ version: '<Version>' , # Not required if custom image is being used
+ platform: '<OS Type>',
+ availability_set_id: '<Availability Set Id>', # [Optional]
+ password: '<Password>', # [Optional], if 'platform' partameter is 'Linux'.
+ vhd_path: '<Path of VHD>', # [Optional], if you want to create the VM from a custom image.
+ custom_data: '<Custom Data Value>', # [Optional], if you want to add custom data in this VM.
+ os_disk_caching: '<Caching Type>', # [Optional], can be one of None, ReadOnly, ReadWrite
+ managed_disk_storage_type: '<Storage Account Type>', # [Optional], can be StandardLRS or PremiumLRS
+ os_disk_size: <Disk Size> # [Optional], size of the os disk in GB (upto 1023)
+)
```
Following methods are available to handle async respoonse:
- state
- pending?
- rejected?
@@ -145,293 +149,291 @@
break
end
end
```
-For more information about custom_data; see link: https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx
+For more information about custom_data, see link: https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx
## List Servers
List servers in a resource group
```ruby
- servers = azure_compute_service.servers(resource_group: '<Resource Group name>')
- servers.each do |server|
+servers = fog_compute_service.servers(resource_group: '<Resource Group Name>')
+servers.each do |server|
puts "#{server.name}"
puts "#{server.location}"
- end
+end
```
## Retrieve a single Server
Get a single record of Server
```ruby
- server = azure_compute_service
- .servers(resource_group: '<Resource Group name>')
- .get('<Resource Group name>', 'Server name>')
- puts "#{server.name}"
+server = fog_compute_service
+ .servers(resource_group: '<Resource Group Name>')
+ .get('<Resource Group Name>', 'Server Name>')
+puts "#{server.name}"
```
-## Attach a Data Disk to Server
+## Get a Server's status
-Get the server object and attach a Data Disk to it.
+Check the status of a Server
-```ruby
- server.attach_data_disk('<Disk Name>', <Size in GB>, '<Storage Account Name>')
+```ruby
+status = fog_compute_service
+ .servers
+ .get('<Resource Group Name>', '<Server Name>')
+ .vm_status
+puts status
```
-## Detach a Data Disk from Server
+## Destroy a single Server
-Get the server object and detach a Data Disk from it.
+Get a server object from the get method (described above) and then destroy that server.
```ruby
- server.detach_data_disk('<Disk Name>')
+server.destroy
```
-## Attach a Managed Data Disk to Server
+## Attach a Data Disk to Server
-Get the server object and attach a Data Disk to it.
+Get the server object and attach a Data Disk to it. The data disk attached is blob based.
```ruby
- server.attach_managed_disk('<Disk Name>', '<Disk Resource Group Name>')
+server.attach_data_disk('<Disk Name>', <Size in GBs>, '<Storage Account Name>')
```
-## Detach a Managed Data Disk from Server
+## Detach a Data Disk from Server
Get the server object and detach a Data Disk from it.
```ruby
- server.detach_managed_disk('<Disk Name>')
+server.detach_data_disk('<Disk Name>')
```
-## Get a Server's status
+## Create Managed Disk
-Check the status of a Server
+Create a new Premium Managed Disk
-```ruby
- status = azure_compute_service
- .servers
- .get('<Resource Group name>', '<Server name>')
- .vm_status
- puts status
+```ruby
+fog_compute_service.managed_disks.create(
+ name: '<Disk Name>',
+ location: '<Location>',
+ resource_group_name: '<Resource Group Name>',
+ account_type: '<Storage Account Type>',
+ disk_size_gb: <Disk Size in GBs>,
+ creation_data: {
+ create_option: '<Create Option Value>'
+ }
+)
```
-## Destroy a single Server
+Create a new Standard Managed Disk
-Get a server object from the get method(described above) and then destroy that server.
-
```ruby
- server.destroy
+fog_compute_service.managed_disks.create(
+ name: '<Disk Name>',
+ location: '<Location>',
+ resource_group_name: '<Resource Group Name>',
+ account_type: '<Storage Account Type>',
+ disk_size_gb: <Disk Size in GBs>,
+ creation_data: {
+ create_option: '<Create Option Value>'
+ }
+)
```
-## Check Availability Set Existence
+## Attach a Managed Data Disk to Server
+Get the server object and attach a Data Disk to it.
+
```ruby
-azure_compute_service.availability_sets.check_availability_set_exists(<Resource Group name>, <Availability Set name>)
+server.attach_managed_disk('<Disk Name>', '<Disk Resource Group Name>')
```
-## Create Availability Set
+## Detach a Managed Data Disk from Server
-Create a new availability set
+Get the server object and detach a Data Disk from it.
```ruby
-azure_compute_service.availability_sets.create(
- name: '<Availability Set name>',
- location: '<Location>',
- resource_group: '<Resource Group name>'
- platform_fault_domain_count: <No of Fault Domains>, # [Optional] Default => 2
- platform_update_domain_count: <No of Update Domains>, # [Optional] Default => 5
- use_managed_disk: true # [Optional] Possible values true or false
-)
+server.detach_managed_disk('<Disk Name>')
```
-## List Availability Sets
-List availability sets in a resource group
+## List Managed Disks in a Resource Group
+List managed disks in a resource group
+
```ruby
- availability_sets = azure_compute_service.availability_sets(resource_group: '<Resource Group name>')
- availability_sets.each do |availability_set|
- puts "#{availability_set.name}"
- puts "#{availability_set.location}"
- end
+managed_disks = fog_compute_service.managed_disks(resource_group: '<Resource Group Name>')
+mnaged_disks.each do |disk|
+ puts "#{disk.name}"
+ puts "#{disk.location}"
+end
```
-## Retrieve a single Availability Set
+## List Managed Disks in a Subscription
-Get a single record of Availability Set
+List managed disks in a subscription
```ruby
- availability_set = azure_compute_service
- .availability_sets
- .get('<Resource Group name>','<Availability Set name>')
- puts "#{availability_set.name}"
+fog_compute_service.managed_disks.each do |disk|
+ puts "#{disk.name}"
+ puts "#{disk.location}"
+end
```
-## Destroy a single Availability Set
+## Grant Access to a Managed Disk
-Get an availability set object from the get method and then destroy that availability set.
+Grant access to a managed disk
```ruby
- availability_set.destroy
+access_sas = fog_compute_service.managed_disks.grant_access('<Resource Group Name>', '<Disk Name>', '<Access Type>', <Duration in Seconds>)
+puts "Access SAS: #{access_sas}"
```
-## Check Virtual Machine Extension Existence
+## Revoke Access from a Managed Disk
+Revoke access from a managed disk
+
```ruby
-azure_compute_service.virtual_machine_extensions.check_vm_extension_exists(<Resource Group name>, <Virtual Machine Name>, <Extension Name>)
+response = fog_compute_service.managed_disks.revoke_access('<Resource Group Name>', '<Disk Name>')
+puts "Revoke Access response status: #{response.status}"
```
-## Create Virtual Machine Extension
+## Check Managed Disk Existence
-Installs an extension to the specified virtual machine.
-
```ruby
- azure_compute_service.virtual_machine_extensions.create(
- name: <Extension Name>,
- resource_group: <Resource Group>,
- location: <Location>,
- vm_name: <Virtual Machine Name>, # Extension will be installed on this VM
- publisher: <Extension publisher>,
- type: <Extension type>,
- type_handler_version: <Extension version>,
- auto_upgrade_minor_version: <true|false>, # Optional
- settings: {JSON object}, # Format: {"key": "value", "key": {"key": "value"}}
- protected_settings: {JSON object}
- )
+fog_compute_service.managed_disks.check_managed_disk_exists('<Resource Group Name>', '<Disk Name>')
```
-## Get Extension from Virtual Machine
+## Retrieve a single Managed Disk
-Retrieves the given extension from the virtual machine
+Get a single record of managed disks
```ruby
- vm_extension = azure_compute_service.virtual_machine_extensions.get(
- '<Resource Group Name>', '<Virtual Machine Name>', '<Extension Name>'
- )
+managed_disk = fog_compute_service
+ .managed_disks
+ .get('<Resource Group Name>', '<Disk Name>')
+puts "#{managed_disk.name}"
```
-## Update Extension
+## Destroy a single Managed Disk
-Update the given extension. The attributes that can be modified are
-- auto_upgrade_minor_version
-- settings
-- protected_settings
+Get an managed disk object from the get method and then destroy that managed disk.
```ruby
- vm_extension.update(
- auto_upgrade_minor_version: <true|false>,
- settings: {JSON object},
- protected_settings: {JSON object}
- )
+managed_disk.destroy
```
-## Destroy Extension
+## Check Availability Set Existence
-Destroy the given extension from the virtual machine
-
```ruby
- vm_extension.destroy
+fog_compute_service.availability_sets.check_availability_set_exists('<Resource Group Name>', '<Availability Set Name>')
```
+## Create Availability Set
-## Create Managed Disk
+Create a new availability set
-Create a new Premium Managed Disk
-
```ruby
- azure_compute_service.managed_disks.create(
- name: 'disk_name',
- location: 'east us',
- resource_group_name: 'resource_group_name',
- account_type: 'Premium_LRS',
- disk_size_gb: 1023,
- creation_data: {
- create_option: 'Empty'
- }
- )
+fog_compute_service.availability_sets.create(
+ name: '<Availability Set Name>',
+ location: '<Location>',
+ resource_group: '<Resource Group Name>'
+ platform_fault_domain_count: <No of Fault Domains>, # [Optional] Default => 2
+ platform_update_domain_count: <No of Update Domains>, # [Optional] Default => 5
+ use_managed_disk: true # [Optional] Possible values true or false
+)
```
+## List Availability Sets
-Create a new Standard Managed Disk
+List availability sets in a resource group
```ruby
- azure_compute_service.managed_disks.create(
- name: 'disk_name',
- location: 'east us',
- resource_group_name: 'resource_group_name',
- account_type: 'Standard_LRS',
- disk_size_gb: 1023,
- creation_data: {
- create_option: 'Empty'
- }
- )
+availability_sets = fog_compute_service.availability_sets(resource_group: '<Resource Group Name>')
+availability_sets.each do |availability_set|
+ puts "#{availability_set.name}"
+ puts "#{availability_set.location}"
+end
```
-## List Managed Disks in a Resource Group
+## Retrieve a single Availability Set
-List managed disks in a resource group
+Get a single record of Availability Set
```ruby
- managed_disks = azure_compute_service.managed_disks(resource_group: '<Resource Group name>')
- mnaged_disks.each do |disk|
- puts "#{disk.name}"
- puts "#{disk.location}"
- end
+availability_set = fog_compute_service
+ .availability_sets
+ .get('<Resource Group Name>','<Availability Set Name>')
+puts "#{availability_set.name}"
```
-## List Managed Disks in a Subscription
+## Destroy a single Availability Set
-List managed disks in a subscription
+Get an availability set object from the get method and then destroy that availability set.
```ruby
- azure_compute_service.managed_disks.each do |disk|
- puts "#{disk.name}"
- puts "#{disk.location}"
- end
+availability_set.destroy
```
-## Grant Access to a Managed Disk
+## Check Virtual Machine Extension Existence
-Grant access to a managed disk
-
```ruby
- access_sas = azure_compute_service.managed_disks.grant_access('<resource_group_name>', '<disk_name>', 'Read', 1000)
- puts "Access SAS: #{access_sas}"
+fog_compute_service.virtual_machine_extensions.check_vm_extension_exists('<Resource Group Name>', '<Virtual Machine Name>', '<Extension Name>')
```
-## Revoke Access from a Managed Disk
+## Create Virtual Machine Extension
-Revoke access from a managed disk
+Installs an extension to the specified virtual machine.
```ruby
- response = azure_compute_service.managed_disks.revoke_access('<resource_group_name>', '<disk_name>')
- puts "Revoke Access response status: #{response.status}"
+fog_compute_service.virtual_machine_extensions.create(
+ name: '<Extension Name>',
+ resource_group: '<Resource Group Name>',
+ location: '<Location>',
+ vm_name: '<Virtual Machine Name>', # Extension will be installed on this VM
+ publisher: '<Extension Publisher>',
+ type: '<Extension Type>',
+ type_handler_version: '<Extension Version>',
+ settings: {JSON object}, # Format: {"key": "value", "key": {"key": "value"}}
+ protected_settings: {JSON object},
+ auto_upgrade_minor_version: <True/False> , # Optional
+)
```
-## Check Managed Disk Existence
+## Get Extension from Virtual Machine
+Retrieves the given extension from the virtual machine
+
```ruby
- azure_compute_service.managed_disks.check_managed_disk_exists(<Resource Group name>, <Disk name>)
+vm_extension = fog_compute_service.virtual_machine_extensions.get(
+ '<Resource Group Name>', '<Virtual Machine Name>', '<Extension Name>'
+)
```
-## Retrieve a single Managed Disk
+## Update Extension
-Get a single record of managed disks
+Update the given extension. The attributes that can be modified are
+- auto_upgrade_minor_version
+- settings
+- protected_settings
```ruby
- managed_disk = azure_compute_service
- .managed_disks
- .get('<Resource Group name>','<Disk name>')
- puts "#{managed_disk.name}"
+vm_extension.update(
+ auto_upgrade_minor_version: <True/False>,
+ settings: {JSON object},
+ protected_settings: {JSON object}
+)
```
-## Destroy a single Managed Disk
+## Destroy Extension
-Get an managed disk object from the get method and then destroy that managed disk.
+Destroy the given extension from the virtual machine
```ruby
- managed_disk.destroy
+vm_extension.destroy
```
-
## Support and Feedback
Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.