lib/fog/azurerm/docs/compute.md in fog-azure-rm-0.2.7 vs lib/fog/azurerm/docs/compute.md in fog-azure-rm-0.3.0
- old
+ new
@@ -33,21 +33,24 @@
## Create Server
Create a new linux 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.
+
```ruby
azure_compute_service.servers.create(
name: '<VM Name>',
location: 'West US',
resource_group: '<Resource Group Name>',
vm_size: 'Basic_A0',
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_id: '/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}',
+ network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
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',
@@ -67,20 +70,75 @@
vm_size: 'Basic_A0',
storage_account_name: '<Storage Account Name>',
username: '<Username for VM>',
password: '<Password for VM>',
disable_password_authentication: false,
- network_interface_card_id: '/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}',
+ network_interface_card_ids: ['/subscriptions/{Subscription-Id}/resourceGroups/{Resource-Group-Name}/providers/Microsoft.Network/networkInterfaces/{Network-Interface-Id}'],
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.
)
```
+
+## Create Server Asynchronously
+
+Create a new linux server asynchronously
+
+```ruby
+ async_response = azure_compute_service.servers.create_async(
+ name: '<VM Name>',
+ location: 'West US',
+ resource_group: '<Resource Group Name>',
+ vm_size: 'Basic_A0',
+ 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}'],
+ 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
+ )
+```
+Following methods are available to handle async respoonse:
+- state
+- pending?
+- rejected?
+- reason
+- fulfilled?
+- value
+
+An example of handling async response is given below:
+
+```ruby
+while 1
+ puts async_response.state
+
+ if async_response.pending?
+ sleep(2)
+ end
+
+ if async_response.fulfilled?
+ puts async_response.value.inspect
+ break
+ end
+
+ if async_response.rejected?
+ puts async_response.reason.inspect
+ break
+ end
+ end
+```
For more information about custom_data; see link: https://msdn.microsoft.com/en-us/library/azure/mt163591.aspx
## List Servers
@@ -244,8 +302,93 @@
Destroy the given extension from the virtual machine
```ruby
vm_extension.destroy
```
+
+
+## Create Managed Disk
+
+Create a new 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'
+ }
+ )
+```
+
+## List Managed Disks in a Resource Group
+
+List managed disks in a resource group
+
+```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
+```
+
+## List Managed Disks in a Subscription
+
+List managed disks in a subscription
+
+```ruby
+ azure_compute_service.managed_disks.each do |disk|
+ puts "#{disk.name}"
+ puts "#{disk.location}"
+ end
+```
+
+## Grant Access to a Managed Disk
+
+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}"
+```
+
+## Revoke Access from a Managed Disk
+
+Revoke access from a managed disk
+
+```ruby
+ response = azure_compute_service.managed_disks.revoke_access('<resource_group_name>', '<disk_name>')
+ puts "Revoke Access response status: #{response.status}"
+```
+
+## Check Managed Disk Existence
+
+```ruby
+ azure_compute_service.managed_disks.check_managed_disk_exists(<Resource Group name>, <Disk name>)
+```
+
+## Retrieve a single Managed Disk
+
+Get a single record of managed disks
+
+```ruby
+ managed_disk = azure_compute_service
+ .managed_disks
+ .get('<Resource Group name>','<Disk name>')
+ puts "#{managed_disk.name}"
+```
+
+## Destroy a single Managed Disk
+
+Get an managed disk object from the get method and then destroy that managed disk.
+
+```ruby
+ managed_disk.destroy
+```
+
## Support and Feedback
Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.