fog-azure-rm-temp 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.arclint +8 -0
- data/.travis.yml +28 -14
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTORS.md +4 -0
- data/fog-azure-rm.gemspec +3 -2
- data/lib/fog/azurerm.rb +1 -0
- data/lib/fog/azurerm/async_response.rb +9 -1
- data/lib/fog/azurerm/compute.rb +3 -1
- data/lib/fog/azurerm/constants.rb +11 -3
- data/lib/fog/azurerm/dns.rb +3 -1
- data/lib/fog/azurerm/docs/application_gateway.md +119 -117
- data/lib/fog/azurerm/docs/compute.md +299 -202
- data/lib/fog/azurerm/docs/dns.md +44 -43
- data/lib/fog/azurerm/docs/key_vault.md +31 -28
- data/lib/fog/azurerm/docs/network.md +407 -404
- data/lib/fog/azurerm/docs/resources.md +52 -49
- data/lib/fog/azurerm/docs/sql.md +56 -54
- data/lib/fog/azurerm/docs/storage.md +92 -157
- data/lib/fog/azurerm/docs/traffic_manager.md +55 -53
- data/lib/fog/azurerm/models/application_gateway/gateway.rb +5 -1
- data/lib/fog/azurerm/models/compute/availability_set.rb +4 -1
- data/lib/fog/azurerm/models/compute/managed_disk.rb +0 -1
- data/lib/fog/azurerm/models/compute/server.rb +61 -11
- data/lib/fog/azurerm/models/compute/servers.rb +2 -2
- data/lib/fog/azurerm/models/dns/a_record.rb +15 -0
- data/lib/fog/azurerm/models/dns/cname_record.rb +15 -0
- data/lib/fog/azurerm/models/dns/record_set.rb +20 -8
- data/lib/fog/azurerm/models/key_vault/vault.rb +3 -1
- data/lib/fog/azurerm/models/network/load_balancer.rb +3 -1
- data/lib/fog/azurerm/models/network/local_network_gateway.rb +3 -1
- data/lib/fog/azurerm/models/network/network_interface.rb +3 -1
- data/lib/fog/azurerm/models/network/network_security_group.rb +4 -2
- data/lib/fog/azurerm/models/network/public_ip.rb +4 -2
- data/lib/fog/azurerm/models/network/virtual_network.rb +4 -2
- data/lib/fog/azurerm/models/resources/resource_group.rb +3 -1
- data/lib/fog/azurerm/models/sql/sql_database.rb +3 -3
- data/lib/fog/azurerm/models/sql/sql_server.rb +3 -2
- data/lib/fog/azurerm/models/storage/directories.rb +6 -1
- data/lib/fog/azurerm/models/storage/file.rb +2 -0
- data/lib/fog/azurerm/models/storage/storage_account.rb +4 -1
- data/lib/fog/azurerm/models/storage/storage_accounts.rb +7 -0
- data/lib/fog/azurerm/models/traffic_manager/traffic_manager_profile.rb +3 -1
- data/lib/fog/azurerm/requests/application_gateway/check_ag_exists.rb +1 -1
- data/lib/fog/azurerm/requests/application_gateway/create_or_update_application_gateway.rb +1 -0
- data/lib/fog/azurerm/requests/compute/attach_data_disk_to_vm.rb +2 -2
- data/lib/fog/azurerm/requests/compute/check_availability_set_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_managed_disk_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_vm_exists.rb +1 -1
- data/lib/fog/azurerm/requests/compute/check_vm_extension_exists.rb +2 -2
- data/lib/fog/azurerm/requests/compute/create_availability_set.rb +4 -2
- data/lib/fog/azurerm/requests/compute/create_image.rb +68 -0
- data/lib/fog/azurerm/requests/compute/create_virtual_machine.rb +302 -135
- data/lib/fog/azurerm/requests/compute/delete_image.rb +29 -0
- data/lib/fog/azurerm/requests/compute/get_image.rb +45 -0
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/requests/dns/check_record_set_exists.rb +1 -1
- data/lib/fog/azurerm/requests/dns/check_zone_exists.rb +3 -2
- data/lib/fog/azurerm/requests/dns/create_or_update_record_set.rb +3 -2
- data/lib/fog/azurerm/requests/dns/create_or_update_zone.rb +1 -2
- data/lib/fog/azurerm/requests/key_vault/check_vault_exists.rb +1 -1
- data/lib/fog/azurerm/requests/key_vault/create_or_update_vault.rb +1 -0
- data/lib/fog/azurerm/requests/network/check_express_route_cir_auth_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_express_route_circuit_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_load_balancer_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_local_net_gateway_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_net_sec_group_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_net_sec_rule_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_network_interface_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_public_ip_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_subnet_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_virtual_network_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_connection_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/check_vnet_gateway_exists.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_load_balancer.rb +4 -4
- data/lib/fog/azurerm/requests/network/create_or_update_express_route_circuit.rb +1 -1
- data/lib/fog/azurerm/requests/network/create_or_update_local_network_gateway.rb +1 -2
- data/lib/fog/azurerm/requests/network/create_or_update_network_interface.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_network_security_group.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_public_ip.rb +5 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network.rb +4 -3
- data/lib/fog/azurerm/requests/network/create_or_update_virtual_network_gateway_connection.rb +1 -1
- data/lib/fog/azurerm/requests/resources/check_azure_resource_exists.rb +4 -4
- data/lib/fog/azurerm/requests/resources/create_resource_group.rb +2 -1
- data/lib/fog/azurerm/requests/resources/delete_resource_tag.rb +4 -4
- data/lib/fog/azurerm/requests/resources/tag_resource.rb +4 -4
- data/lib/fog/azurerm/requests/sql/create_or_update_database.rb +13 -10
- data/lib/fog/azurerm/requests/sql/create_or_update_sql_server.rb +8 -5
- data/lib/fog/azurerm/requests/storage/check_storage_account_exists.rb +1 -1
- data/lib/fog/azurerm/requests/storage/create_storage_account.rb +4 -2
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_endpoint_exists.rb +1 -1
- data/lib/fog/azurerm/requests/traffic_manager/check_traffic_manager_profile_exists.rb +1 -1
- data/lib/fog/azurerm/requests/traffic_manager/create_or_update_traffic_manager_profile.rb +13 -3
- data/lib/fog/azurerm/storage.rb +0 -18
- data/lib/fog/azurerm/utilities/general.rb +21 -10
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +7 -1
- data/rakefile +1 -1
- data/test/api_stub.rb +19 -2
- data/test/api_stub/models/compute/server.rb +21 -5
- data/test/api_stub/requests/compute/image.rb +41 -0
- data/test/api_stub/requests/compute/virtual_machine.rb +60 -62
- data/test/api_stub/requests/resources/resource_group.rb +1 -1
- data/test/integration/application_gateway.rb +8 -1
- data/test/integration/availability_set.rb +9 -2
- data/test/integration/external_load_balancer.rb +2 -1
- data/test/integration/internal_load_balancer.rb +2 -1
- data/test/integration/key_vault.rb +2 -1
- data/test/integration/managed_disk.rb +10 -5
- data/test/integration/network_interface.rb +2 -1
- data/test/integration/network_security_group.rb +2 -1
- data/test/integration/public_ip.rb +2 -1
- data/test/integration/record_set.rb +5 -5
- data/test/integration/resource_group.rb +5 -2
- data/test/integration/resource_tag.rb +4 -2
- data/test/integration/server.rb +113 -23
- data/test/integration/server_custom_image.rb +120 -20
- data/test/integration/sql_server.rb +10 -2
- data/test/integration/storage_account.rb +32 -20
- data/test/integration/traffic_manager.rb +6 -1
- data/test/integration/virtual_network.rb +2 -1
- data/test/integration/virtual_network_gateway_connection.rb +3 -3
- data/test/models/application_gateway/test_gateway.rb +2 -1
- data/test/models/compute/test_availability_set.rb +2 -1
- data/test/models/compute/test_managed_disk.rb +2 -1
- data/test/models/compute/test_server.rb +13 -4
- data/test/models/dns/test_zone.rb +2 -1
- data/test/models/key_vault/test_vault.rb +2 -1
- data/test/models/network/test_load_balancer.rb +2 -1
- data/test/models/network/test_network_interface.rb +2 -1
- data/test/models/network/test_network_security_group.rb +2 -1
- data/test/models/network/test_public_ip.rb +2 -1
- data/test/models/network/test_virtual_network.rb +2 -1
- data/test/models/resources/test_resource_group.rb +2 -1
- data/test/models/sql/test_database.rb +2 -1
- data/test/models/sql/test_sql_server.rb +2 -1
- data/test/models/storage/test_storage_account.rb +2 -1
- data/test/models/traffic_manager/test_traffic_manager_profile.rb +2 -1
- data/test/requests/application_gateway/test_check_ag_exists.rb +11 -4
- data/test/requests/compute/test_attach_data_disk_to_vm.rb +2 -2
- data/test/requests/compute/test_check_availability_set_exists.rb +9 -2
- data/test/requests/compute/test_check_managed_disk_exists.rb +9 -2
- data/test/requests/compute/test_check_vm_exists.rb +9 -2
- data/test/requests/compute/test_check_vm_extension_exists.rb +9 -2
- data/test/requests/compute/test_create_image.rb +27 -0
- data/test/requests/compute/test_create_virtual_machine.rb +41 -17
- data/test/requests/compute/test_delete_image.rb +23 -0
- data/test/requests/compute/test_get_image.rb +23 -0
- data/test/requests/dns/test_check_record_set_exists.rb +9 -2
- data/test/requests/dns/test_check_zone_exists.rb +16 -2
- data/test/requests/key_vault/test_check_vault_exists.rb +9 -2
- data/test/requests/network/test_check_express_route_cir_auth_exists.rb +9 -2
- data/test/requests/network/test_check_express_route_circuit_exists.rb +9 -2
- data/test/requests/network/test_check_load_balancer_exists.rb +9 -2
- data/test/requests/network/test_check_local_net_gateway_exists.rb +11 -4
- data/test/requests/network/test_check_net_sec_group_exists.rb +9 -2
- data/test/requests/network/test_check_net_sec_rule_exists.rb +9 -2
- data/test/requests/network/test_check_network_interface_exists.rb +9 -2
- data/test/requests/network/test_check_public_ip_exists.rb +9 -2
- data/test/requests/network/test_check_subnet_exists.rb +9 -2
- data/test/requests/network/test_check_virtual_network_exists.rb +10 -4
- data/test/requests/network/test_check_vnet_gateway_connection_exists.rb +9 -2
- data/test/requests/network/test_check_vnet_gateway_exists.rb +9 -2
- data/test/requests/network/test_create_load_balancer.rb +3 -2
- data/test/requests/network/test_create_network_interface.rb +4 -3
- data/test/requests/network/test_create_or_update_network_security_group.rb +3 -2
- data/test/requests/network/test_create_or_update_virtual_network.rb +5 -3
- data/test/requests/network/test_create_public_ip.rb +3 -2
- data/test/requests/network/test_update_public_ip.rb +3 -2
- data/test/requests/resources/test_create_resource_group.rb +3 -2
- data/test/requests/resources/test_delete_resource_tag.rb +3 -3
- data/test/requests/resources/test_tag_resource.rb +3 -3
- data/test/requests/storage/test_check_storage_account_exists.rb +8 -1
- data/test/requests/traffic_manager/test_check_traffic_manager_endpoint_exists.rb +9 -2
- data/test/requests/traffic_manager/test_check_traffic_manager_profile_exists.rb +9 -2
- data/test/test_helper.rb +5 -14
- metadata +67 -75
- data/lib/fog/azurerm/models/storage/recovery_vault.rb +0 -50
- data/lib/fog/azurerm/models/storage/recovery_vaults.rb +0 -27
- data/lib/fog/azurerm/requests/storage/create_or_update_recovery_vault.rb +0 -54
- data/lib/fog/azurerm/requests/storage/delete_recovery_vault.rb +0 -35
- data/lib/fog/azurerm/requests/storage/disable_backup_protection.rb +0 -60
- data/lib/fog/azurerm/requests/storage/enable_backup_protection.rb +0 -61
- data/lib/fog/azurerm/requests/storage/get_all_backup_jobs.rb +0 -56
- data/lib/fog/azurerm/requests/storage/get_backup_container.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_item.rb +0 -58
- data/lib/fog/azurerm/requests/storage/get_backup_job_for_vm.rb +0 -53
- data/lib/fog/azurerm/requests/storage/get_backup_protection_policy.rb +0 -64
- data/lib/fog/azurerm/requests/storage/get_recovery_vault.rb +0 -49
- data/lib/fog/azurerm/requests/storage/list_recovery_vaults.rb +0 -48
- data/lib/fog/azurerm/requests/storage/set_recovery_vault_context.rb +0 -36
- data/lib/fog/azurerm/requests/storage/start_backup.rb +0 -54
- data/test/api_stub/models/storage/recovery_vault.rb +0 -23
- data/test/api_stub/requests/storage/recovery_vault.rb +0 -189
- data/test/models/storage/test_recovery_vault.rb +0 -61
- data/test/models/storage/test_recovery_vaults.rb +0 -47
- data/test/requests/storage/test_create_recovery_vault.rb +0 -35
- data/test/requests/storage/test_delete_recovery_vault.rb +0 -34
- data/test/requests/storage/test_disable_backup_protection.rb +0 -52
- data/test/requests/storage/test_enable_backup_protection.rb +0 -66
- data/test/requests/storage/test_get_all_backup_jobs.rb +0 -35
- data/test/requests/storage/test_get_backup_container.rb +0 -35
- data/test/requests/storage/test_get_backup_item.rb +0 -35
- data/test/requests/storage/test_get_backup_job_for_vm.rb +0 -26
- data/test/requests/storage/test_get_backup_protection_policy.rb +0 -35
- data/test/requests/storage/test_get_recovery_vault.rb +0 -35
- data/test/requests/storage/test_list_recovery_vault.rb +0 -35
- data/test/requests/storage/test_set_recovery_vault_context.rb +0 -34
- data/test/requests/storage/test_start_backup.rb +0 -55
@@ -1,6 +1,6 @@
|
|
1
|
-
#Resources
|
1
|
+
# Resources
|
2
2
|
|
3
|
-
This document explains how to get started using Azure Resources Service with Fog. With this gem you can create
|
3
|
+
This document explains how to get started using Azure Resources Service with Fog. With this gem you can create, update, list or delete resource groups.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -15,19 +15,19 @@ require 'fog/azurerm'
|
|
15
15
|
Next, create a connection to the Resources Service:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
18
|
+
fog_resources_service = Fog::Resources::AzureRM.new(
|
19
|
+
tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
|
20
|
+
client_id: '<Client Id>', # Client Id of Azure Active Directory Application
|
21
|
+
client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
|
22
|
+
subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
|
23
|
+
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
24
24
|
)
|
25
25
|
```
|
26
26
|
|
27
27
|
## Check Resource Group Existence
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
|
30
|
+
fog_resources_service.resource_groups.check_resource_group_exists('<Resource Group Name>')
|
31
31
|
```
|
32
32
|
|
33
33
|
## Create Resource Group
|
@@ -35,18 +35,19 @@ Next, create a connection to the Resources Service:
|
|
35
35
|
Create a new resource group
|
36
36
|
|
37
37
|
```ruby
|
38
|
-
|
38
|
+
fog_resources_service.resource_groups.create(
|
39
39
|
name: '<Resource Group name>',
|
40
|
-
location: '
|
41
|
-
|
40
|
+
location: '<Location>',
|
41
|
+
tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional]
|
42
|
+
)
|
42
43
|
```
|
43
44
|
## List Resource Groups
|
44
45
|
|
45
46
|
```ruby
|
46
|
-
|
47
|
+
fog_resources_service.resource_groups.each do |resource_group|
|
47
48
|
puts "#{resource_group.name}"
|
48
49
|
puts "#{resource_group.location}"
|
49
|
-
|
50
|
+
end
|
50
51
|
```
|
51
52
|
|
52
53
|
## Retrieve a single Resource Group
|
@@ -54,10 +55,10 @@ Create a new resource group
|
|
54
55
|
Get a single record of Resource Group
|
55
56
|
|
56
57
|
```ruby
|
57
|
-
|
58
|
+
resource_group = fog_resources_service
|
58
59
|
.resource_groups
|
59
|
-
.get('<Resource Group
|
60
|
-
|
60
|
+
.get('<Resource Group Name>')
|
61
|
+
puts "#{resource_group.name}"
|
61
62
|
```
|
62
63
|
|
63
64
|
## Destroy a single Resource Group
|
@@ -65,69 +66,71 @@ Get a single record of Resource Group
|
|
65
66
|
Get resource group object from the get method(described above) and then destroy that resource group.
|
66
67
|
|
67
68
|
```ruby
|
68
|
-
|
69
|
+
resource_group.destroy
|
69
70
|
```
|
70
71
|
## Tagging a Resource
|
71
72
|
|
72
73
|
You can tag a Resource as following:
|
73
74
|
|
74
75
|
```ruby
|
75
|
-
|
76
|
-
'<Resource
|
77
|
-
'<Tag
|
78
|
-
'<Tag
|
79
|
-
|
76
|
+
fog_resources_service.tag_resource(
|
77
|
+
'<Resource Id>',
|
78
|
+
'<Tag Key>',
|
79
|
+
'<Tag Value>',
|
80
|
+
'<API Version>'
|
81
|
+
)
|
80
82
|
```
|
81
83
|
|
82
84
|
## List Tagged Resources in a Subscription
|
83
85
|
|
84
86
|
```ruby
|
85
|
-
|
87
|
+
fog_resources_service.azure_resources(tag_name: '<Tag Key>', tag_value: '<Tag Value>').each do |resource|
|
86
88
|
puts "#{resource.name}"
|
87
89
|
puts "#{resource.location}"
|
88
90
|
puts "#{resource.type}"
|
89
|
-
|
91
|
+
end
|
90
92
|
```
|
91
93
|
OR
|
92
94
|
```ruby
|
93
|
-
|
95
|
+
fog_resources_service.azure_resources(tag_name: '<Tag Key>').each do |resource|
|
94
96
|
puts "#{resource.name}"
|
95
97
|
puts "#{resource.location}"
|
96
98
|
puts "#{resource.type}"
|
97
|
-
|
99
|
+
end
|
98
100
|
```
|
99
101
|
## Retrieve a single Resource
|
100
102
|
|
101
103
|
Get a single record of Tagged Resources
|
102
104
|
|
103
105
|
```ruby
|
104
|
-
|
105
|
-
.azure_resources(tag_name: '<Tag
|
106
|
-
.get('<Resource
|
107
|
-
|
106
|
+
resource = fog_resources_service
|
107
|
+
.azure_resources(tag_name: '<Tag Key>')
|
108
|
+
.get('<Resource Id>')
|
109
|
+
puts "#{resource.name}"
|
108
110
|
```
|
109
111
|
## Remove tag from a Resource
|
110
112
|
|
111
113
|
Remove tag from a resource as following:
|
112
114
|
|
113
115
|
```ruby
|
114
|
-
|
115
|
-
'<Resource
|
116
|
-
'<Tag
|
117
|
-
'<Tag
|
118
|
-
|
116
|
+
fog_resources_service.delete_resource_tag(
|
117
|
+
'<Resource Id>',
|
118
|
+
'<Tag Key>',
|
119
|
+
'<Tag Value>',
|
120
|
+
'<API Version>'
|
121
|
+
)
|
119
122
|
```
|
120
123
|
|
121
124
|
## Check Resource Existence
|
122
125
|
|
123
126
|
```ruby
|
124
|
-
|
127
|
+
fog_resources_service.azure_resources.check_azure_resource_exists('<Resource Id>', '<API Version>')
|
125
128
|
```
|
126
129
|
|
127
130
|
## Check Deployment Existence
|
128
131
|
|
129
132
|
```ruby
|
130
|
-
|
133
|
+
fog_resources_service.deployments.check_deployment_exists('<Resource Group Name>', '<Deployment Name>')
|
131
134
|
```
|
132
135
|
|
133
136
|
## Create Deployment
|
@@ -135,21 +138,21 @@ Remove tag from a resource as following:
|
|
135
138
|
Create a Deployment
|
136
139
|
|
137
140
|
```ruby
|
138
|
-
|
139
|
-
name: '<Deployment
|
140
|
-
resource_group: '<Resource Group
|
141
|
+
fog_resources_service.deployments.create(
|
142
|
+
name: '<Deployment Name>',
|
143
|
+
resource_group: '<Resource Group Name>',
|
141
144
|
template_link: '<Template Link>',
|
142
145
|
parameters_link: '<Parameters Link>'
|
143
|
-
|
146
|
+
)
|
144
147
|
```
|
145
148
|
## List Deployments
|
146
149
|
|
147
150
|
List Deployments in a resource group
|
148
151
|
|
149
152
|
```ruby
|
150
|
-
|
153
|
+
fog_resources_service.deployments(resource_group: '<Resource Group Name>').each do |deployment|
|
151
154
|
puts "#{deployment.name}"
|
152
|
-
|
155
|
+
end
|
153
156
|
```
|
154
157
|
|
155
158
|
## Retrieve a single Deployment
|
@@ -157,10 +160,10 @@ List Deployments in a resource group
|
|
157
160
|
Get a single record of Deployment
|
158
161
|
|
159
162
|
```ruby
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
163
|
+
deployment = fog_resources_service
|
164
|
+
.deployments
|
165
|
+
.get('<Resource Group Name>', '<Deployment Name>')
|
166
|
+
puts "#{deployment.name}"
|
164
167
|
```
|
165
168
|
|
166
169
|
## Destroy a single Deployment
|
@@ -168,7 +171,7 @@ Get a single record of Deployment
|
|
168
171
|
Get Deployment object from the get method(described above) and then destroy that Deployment.
|
169
172
|
|
170
173
|
```ruby
|
171
|
-
|
174
|
+
deployment.destroy
|
172
175
|
```
|
173
176
|
|
174
177
|
## Support and Feedback
|
data/lib/fog/azurerm/docs/sql.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#Azure SQL
|
1
|
+
# Azure SQL
|
2
2
|
|
3
3
|
This document explains how to get started using Azure SQL Services with Fog.
|
4
4
|
|
@@ -15,16 +15,16 @@ require 'fog/azurerm'
|
|
15
15
|
Next, create a connection to the SQL Service:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
18
|
+
fog_sql_service = Fog::Sql::AzureRM.new(
|
19
|
+
tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
|
20
|
+
client_id: '<Client Id>', # Client Id of Azure Active Directory Application
|
21
|
+
client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
|
22
|
+
subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
|
23
|
+
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
24
|
+
)
|
25
25
|
```
|
26
26
|
|
27
|
-
The
|
27
|
+
The _server-name_ and _database-name_ value must be set using all lowercase ANSI letters , hyphen, and the numbers 1 through 9. Do not use a hyphen as the leading or trailing character.
|
28
28
|
|
29
29
|
|
30
30
|
## Create SQL Server
|
@@ -32,24 +32,25 @@ The {server-name} and {database-name} value must be set using all lowercase ANSI
|
|
32
32
|
Create a new Server
|
33
33
|
|
34
34
|
```ruby
|
35
|
-
|
35
|
+
fog_sql_service.sql_servers.create(
|
36
36
|
name: '<Unique Server Name>',
|
37
37
|
resource_group: '<Resource Group Name>',
|
38
|
-
location: '
|
39
|
-
version: '
|
40
|
-
administrator_login: '
|
41
|
-
administrator_login_password: '
|
42
|
-
|
38
|
+
location: '<Location>',
|
39
|
+
version: '<Version Number>', # Specifies the version of the Azure server. The acceptable value are: '2.0' or '12.0'
|
40
|
+
administrator_login: '<Admin Username>', # Specifies the name of the SQL administrator.
|
41
|
+
administrator_login_password: '<Admin Password>', # Specifies the password of the SQL administrator.
|
42
|
+
tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional]
|
43
|
+
)
|
43
44
|
```
|
44
45
|
For more information, see link: https://msdn.microsoft.com/en-us/library/azure/mt297738.aspx
|
45
46
|
|
46
47
|
## List SQL Servers
|
47
48
|
Get a list of servers in given resource group
|
48
49
|
```ruby
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
servers = fog_sql_service.sql_servers(resource_group: '<Resource Group Name>')
|
51
|
+
servers.each do |server|
|
52
|
+
puts "Listing : #{server.name}"
|
53
|
+
end
|
53
54
|
```
|
54
55
|
|
55
56
|
## Retrieve a single SQL Server
|
@@ -57,9 +58,9 @@ Get a list of servers in given resource group
|
|
57
58
|
Get a single record of SQL Server
|
58
59
|
|
59
60
|
```ruby
|
60
|
-
|
61
|
-
|
62
|
-
|
61
|
+
server = fog_sql_service.sql_servers
|
62
|
+
.get('<Resource Group Name>', '<Server Name>')
|
63
|
+
puts "Server Name: #{server.name}"
|
63
64
|
```
|
64
65
|
|
65
66
|
## Destroy a SQL Server
|
@@ -67,32 +68,33 @@ Get a single record of SQL Server
|
|
67
68
|
Get SQL Server object from the get method(described above) and destroy that Server.
|
68
69
|
|
69
70
|
```ruby
|
70
|
-
|
71
|
+
server.destroy
|
71
72
|
```
|
72
73
|
|
73
74
|
## Create SQL Database
|
74
75
|
|
75
76
|
Creates a new Sql Database
|
76
77
|
|
77
|
-
In parameter
|
78
|
+
In parameter _create_mode_: 'Copy', 'NonReadableSecondary', and 'OnlineSecondary' are not supported by SQL Data Warehouse.
|
78
79
|
|
79
|
-
If parameter
|
80
|
+
If parameter _edition_ is set to DataWarehouse, the acceptable values for parameter _requested_service_objective_name_ are: ['DW100', 'DW200', 'DW300', 'DW400', 'DW500', 'DW600', 'DW1000', 'DW1200', 'DW1500', 'DW2000', 'DW3000', 'DW6000']
|
80
81
|
|
81
82
|
```ruby
|
82
|
-
|
83
|
+
fog_sql_service.sql_databases.create(
|
83
84
|
resource_group: '<Resource Group Name>',
|
84
|
-
location: '
|
85
|
+
location: '<Location>',
|
85
86
|
server_name: '<Server Name>',
|
86
87
|
name: '<Database Name>',
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
88
|
+
edition: '<Edition Type>', # Conditional. Specifies the edition of the database. If createMode is set to Default, then this value must be specified. The acceptable value are: [Basic, Standard, Premium, DataWarehouse]
|
89
|
+
source_database_id: '<URI>', # Conditional. Specifies the URI of the source database. If createMode is not set to Default, then this value must be specified.
|
90
|
+
collation: '<Collation>', # Conditional. Specifies the name of the collation. If createMode is set to Default, then this value must be specified.
|
91
|
+
max_size_bytes: '<Size in Bytes>', # Conditional. Specifies the maximum size to which the database may grow. If createMode is set to Default, then this value must be specified.
|
92
|
+
requested_service_objective_name: '<Name>', # Conditional. Specifies the requested service level of the database. If requestedServiceObjectiveId is specified, then this value must not be specified. The acceptable value are: [Basic, S0, S1, S2, S3, P1, P2, P4, P6, P11, ElasticPool]
|
93
|
+
elastic_pool_name: '<Pool Name>', # Conditional. Specifies the name of the elastic database pool. If requestedServiceObjectiveId or requestedServiceObjectiveName is set to ElasticPool, then this value must be specified.
|
94
|
+
requested_service_objective_id: '<GUID>', # Conditional. Specifies the identifier of the requested service level. If requestedServiceObjectiveName is specified, then this value must not be specified.
|
95
|
+
tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' }, # [Optional]
|
96
|
+
create_mode: '<Create Mode Type>' # [Optional]. Specifies the type of database to create. The default value is Default. The acceptable values are: [Copy, Default, NonReadableSecondary, OnlineSecondary, PointInTimeRestore, PointInTimeRestore, Restore]
|
97
|
+
)
|
96
98
|
```
|
97
99
|
For more information see link: https://msdn.microsoft.com/en-us/library/azure/mt163685.aspx
|
98
100
|
|
@@ -100,10 +102,10 @@ For more information see link: https://msdn.microsoft.com/en-us/library/azure/mt
|
|
100
102
|
Get a list of databases in given resource group
|
101
103
|
|
102
104
|
```ruby
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
databases = fog_sql_service.sql_databases(resource_group: '<Resource Group Name>', server_name: '<Server Name>')
|
106
|
+
databases.each do |database|
|
107
|
+
puts "Listing : #{database.name}"
|
108
|
+
end
|
107
109
|
```
|
108
110
|
|
109
111
|
## Retrieve a single SQL Database
|
@@ -111,17 +113,17 @@ Get a list of databases in given resource group
|
|
111
113
|
Get a single record of SQL Database
|
112
114
|
|
113
115
|
```ruby
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
database = fog_sql_service.sql_databases
|
117
|
+
.get('<Resource Group Name>', '<Server Name>', '<Database Name>')
|
118
|
+
puts "Database Name: #{database.name}"
|
117
119
|
```
|
118
120
|
|
119
|
-
## Destroy a SQL Database
|
121
|
+
## Destroy a single SQL Database
|
120
122
|
|
121
123
|
Get SQL Database object from the get method(described above) and destroy that Database.
|
122
124
|
|
123
125
|
```ruby
|
124
|
-
|
126
|
+
database.destroy
|
125
127
|
```
|
126
128
|
|
127
129
|
## Create Firewall Rule
|
@@ -129,38 +131,38 @@ Get SQL Database object from the get method(described above) and destroy that Da
|
|
129
131
|
Create a new Firewall Rule
|
130
132
|
|
131
133
|
```ruby
|
132
|
-
|
134
|
+
fog_sql_service.firewall_rules.create(
|
133
135
|
name: '<Firewall Rule Name>',
|
134
136
|
resource_group: '<Resource Group Name>',
|
135
137
|
server_location: '<Server Name>',
|
136
138
|
start_ip: '<Start IP Address>', # Specifies the starting IP address to allow through the firewall.
|
137
139
|
end_ip: '<End IP Address>', # Specifies the ending IP address to allow through the firewall.
|
138
140
|
|
139
|
-
|
141
|
+
)
|
140
142
|
```
|
141
143
|
|
142
144
|
## List Firewall Rules
|
143
145
|
Get a list of Firewall Rules on a SQL Server in given resource group
|
144
146
|
```ruby
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
147
|
+
firewall_rules = fog_sql_service.firewall_rules(resource_group: '<Resource Group Name>', server_name: '<Server Name>')
|
148
|
+
firewall_rules.each do |firewall_rule|
|
149
|
+
puts "Listing : #{firewall_rule.name}"
|
150
|
+
end
|
149
151
|
```
|
150
152
|
|
151
153
|
## Retrieve a single Firewall Rule
|
152
154
|
Get a single record of Firewall rule on SQL Server
|
153
155
|
```ruby
|
154
|
-
|
156
|
+
firewall_rule = fog_sql_service.firewall_rules
|
155
157
|
.get('<Resource Group Name>', '<Server Name>', '<Firewall Rule Name>')
|
156
|
-
|
158
|
+
puts "Get: Firewall Rule Name: #{firewall_rule.name}"
|
157
159
|
```
|
158
160
|
|
159
161
|
## Destroy a Firewall Rule
|
160
162
|
Get Firewall Rule object from the get method(described above) and destroy that Firewall Rule.
|
161
163
|
|
162
164
|
```ruby
|
163
|
-
|
165
|
+
firewall_rule.destroy
|
164
166
|
```
|
165
167
|
|
166
168
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
#Storage
|
1
|
+
# Storage
|
2
2
|
|
3
|
-
This document explains how to get started using Azure Storage Service with Fog. With this gem you can create
|
3
|
+
This document explains how to get started using Azure Storage Service with Fog. With this gem you can create, update, list or delete storage accounts.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
@@ -15,75 +15,76 @@ require 'fog/azurerm'
|
|
15
15
|
Next, create a connection to the Storage Service:
|
16
16
|
|
17
17
|
```ruby
|
18
|
-
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:environment => '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
18
|
+
fog_storage_service = Fog::Storage::AzureRM.new(
|
19
|
+
tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
|
20
|
+
client_id: '<Client Id>', # Client Id of Azure Active Directory Application
|
21
|
+
client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
|
22
|
+
subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
|
23
|
+
azure_storage_account_name: '<Storage Account Name>', # Name of an Azure Storage Account
|
24
|
+
azure_storage_access_key: '<Storage Account Key>', # Key of an Azure Storage Account
|
25
|
+
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
27
26
|
)
|
28
27
|
```
|
29
28
|
|
30
29
|
If you only want to manage the storage accounts, you can create the connection without the storage account information:
|
31
30
|
|
32
31
|
```ruby
|
33
|
-
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:environment => '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
32
|
+
fog_storage_service = Fog::Storage::AzureRM.new(
|
33
|
+
tenant_id: '<Tenant Id>', # Tenant Id of Azure Active Directory Application
|
34
|
+
client_id: '<Client Id>', # Client Id of Azure Active Directory Application
|
35
|
+
client_secret: '<Client Secret>', # Client Secret of Azure Active Directory Application
|
36
|
+
subscription_id: '<Subscription Id>', # Subscription Id of an Azure Account
|
37
|
+
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
40
38
|
)
|
41
39
|
```
|
42
40
|
|
43
41
|
If you only want to manage the storage data, you can create the connection without the Azure subscription information:
|
44
42
|
|
45
43
|
```ruby
|
46
|
-
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
50
|
-
:environment => '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
44
|
+
fog_storage_service = Fog::Storage::AzureRM.new(
|
45
|
+
azure_storage_account_name: '<Storage Account Name>', # Name of an Azure Storage Account
|
46
|
+
azure_storage_access_key: '<Storage Account Key>', # Key of an Azure Storage Account
|
47
|
+
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>' # Azure cloud environment. Default is AzureCloud.
|
51
48
|
)
|
52
49
|
```
|
53
50
|
|
54
51
|
## Check Name Availability
|
55
52
|
|
56
|
-
|
57
|
-
_Storage Account Type_ is an optional parameter
|
53
|
+
This operation checks that account name is valid and is not already in use. _Storage Account Type_ is an optional parameter
|
58
54
|
|
59
55
|
```ruby
|
60
|
-
|
56
|
+
fog_storage_service.storage_accounts.check_name_availability('<Storage Account Name>', '<Storage Account Type>')
|
61
57
|
```
|
62
58
|
|
63
59
|
## Check Storage Account Existence
|
64
60
|
|
65
61
|
```ruby
|
66
|
-
|
62
|
+
fog_storage_service.storage_accounts.check_storage_account_exists('<Resource Group Name>', '<Storage Account Name>')
|
67
63
|
```
|
68
64
|
|
69
65
|
## Create Storage Account
|
70
66
|
|
71
67
|
Create a new storage account. Replication attribute for Standard and Premium account types are as follows
|
72
68
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
69
|
+
##### Standard
|
70
|
+
|
71
|
+
1. LRS (Standard Locally-redundant storage)
|
72
|
+
2. ZRS (Standard Zone-redundant storage)
|
73
|
+
3. GRS (Standard Geo-redundant storage)
|
74
|
+
4. RAGRS (Standard Read access geo-redundant storage)
|
75
|
+
|
76
|
+
##### Premium
|
77
|
+
1. LRS (Premium Locally-redundant storage)
|
78
78
|
|
79
79
|
```ruby
|
80
|
-
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
80
|
+
fog_storage_service.storage_accounts.create(
|
81
|
+
name: '<Storage Account name>',
|
82
|
+
location: '<Location>',
|
83
|
+
resource_group: '<Resource Group Name>',
|
84
|
+
account_type: '<Standard/Premium>', # [Optional] Default value 'Standard'. Allowed values can only be Standard or Premium
|
85
|
+
replication: '<Replication Type>', # [Optional] Default value 'LRS'
|
86
|
+
encryption: <True/False>, # [Optional] Enables encryption. Default is false.
|
87
|
+
tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional]
|
87
88
|
)
|
88
89
|
```
|
89
90
|
Premium Storage account store data on solid state drives (SSDs). For more details on standard and premium storage accounts, see [Introduction to Microsoft Azure Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-introduction/) and [Premium Storage: High-Performance Storage for Azure Virtual Machine Workloads](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage/).
|
@@ -93,7 +94,7 @@ Premium Storage account store data on solid state drives (SSDs). For more detail
|
|
93
94
|
##### List storage accounts in a subscription
|
94
95
|
|
95
96
|
```ruby
|
96
|
-
|
97
|
+
fog_storage_service.storage_accounts.each do |storage_acc|
|
97
98
|
puts "#{storage_acc.name}"
|
98
99
|
puts "#{storage_acc.location}"
|
99
100
|
end
|
@@ -101,7 +102,7 @@ end
|
|
101
102
|
##### List storage accounts in a resource group
|
102
103
|
|
103
104
|
```ruby
|
104
|
-
storage_accounts =
|
105
|
+
storage_accounts = fog_storage_service.storage_accounts(resource_group: '<Resource Group Name>')
|
105
106
|
storage_accounts.each do |storage_acc|
|
106
107
|
puts "#{storage_acc.name}"
|
107
108
|
puts "#{storage_acc.location}"
|
@@ -113,9 +114,9 @@ end
|
|
113
114
|
Get a single record of Storage Account
|
114
115
|
|
115
116
|
```ruby
|
116
|
-
storage_acc =
|
117
|
+
storage_acc = fog_storage_service
|
117
118
|
.storage_accounts
|
118
|
-
.get('<Resource Group
|
119
|
+
.get('<Resource Group Name>', '<Storage Account Name>')
|
119
120
|
puts "#{storage_acc.name}"
|
120
121
|
```
|
121
122
|
|
@@ -124,9 +125,9 @@ puts "#{storage_acc.name}"
|
|
124
125
|
Get a single record of Storage Account and enable encryption on that Storage Account
|
125
126
|
|
126
127
|
```ruby
|
127
|
-
storage_acc =
|
128
|
+
storage_acc = fog_storage_service
|
128
129
|
.storage_accounts
|
129
|
-
.get('<Resource Group
|
130
|
+
.get('<Resource Group Name>', '<Storage Account Name>')
|
130
131
|
|
131
132
|
storage_acc.update(encryption: true)
|
132
133
|
```
|
@@ -152,26 +153,26 @@ storage_acc.destroy
|
|
152
153
|
|
153
154
|
## Create a Disk
|
154
155
|
|
155
|
-
Create a Disk in storage account.
|
156
|
+
Create a Disk in storage account. _disk_size_in_gb_ must be an integer and the range is [1, 1023].
|
156
157
|
By default the disk will be created in the container 'vhds'. You can specify other container by set options[:container_name].
|
157
158
|
|
158
159
|
```ruby
|
159
|
-
|
160
|
+
fog_storage_service.create_disk('<Data Disk Name>', disk_size_in_gb, options = {})
|
160
161
|
```
|
161
162
|
|
162
163
|
## Delete a Disk
|
163
164
|
|
164
|
-
Delete a Disk from a storage account. Disk must be in unlocked state i.e detached from server(virtual machine) to successfully perform this action.
|
165
|
+
Delete a Disk from a storage account. Disk must be in unlocked state i.e detached from server (virtual machine) to successfully perform this action.
|
165
166
|
By default the disk will be deleted from the container 'vhds'. You can specify other container by set options[:container_name].
|
166
167
|
|
167
168
|
```ruby
|
168
|
-
|
169
|
+
fog_storage_service.delete_disk('<Data Disk Name>', options = {})
|
169
170
|
```
|
170
171
|
|
171
172
|
## Check Storage Container Existence
|
172
173
|
|
173
174
|
```ruby
|
174
|
-
|
175
|
+
fog_storage_service.directories.check_container_exists('<Container Name>')
|
175
176
|
```
|
176
177
|
|
177
178
|
## Create a storage container
|
@@ -179,9 +180,9 @@ azure_storage_service.directories.check_container_exists(<container name>)
|
|
179
180
|
Create a storage container in the current storage account.
|
180
181
|
|
181
182
|
```ruby
|
182
|
-
directory =
|
183
|
-
|
184
|
-
|
183
|
+
directory = fog_storage_service.directories.create(
|
184
|
+
key: '<Container Name>',
|
185
|
+
public: <True/False>
|
185
186
|
)
|
186
187
|
puts directory.key
|
187
188
|
```
|
@@ -191,7 +192,7 @@ puts directory.key
|
|
191
192
|
List all the storage containers in the current storage accounts.
|
192
193
|
|
193
194
|
```ruby
|
194
|
-
|
195
|
+
fog_storage_service.directories.each do |directory|
|
195
196
|
puts directory.key
|
196
197
|
end
|
197
198
|
```
|
@@ -201,7 +202,7 @@ end
|
|
201
202
|
Get the permissions for the specified container. The permissions indicate whether container data may be accessed publicly.
|
202
203
|
|
203
204
|
```ruby
|
204
|
-
directory =
|
205
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
205
206
|
puts directory.acl
|
206
207
|
```
|
207
208
|
|
@@ -209,22 +210,22 @@ puts directory.acl
|
|
209
210
|
|
210
211
|
Set the permissions for the specified container. The permissions indicate whether container data may be accessed publicly. The container permissions provide the following options for managing container access:
|
211
212
|
|
212
|
-
-
|
213
|
+
- ###### Container
|
213
214
|
|
214
215
|
Full public read access. Container and blob data can be read via anonymous request. Clients can enumerate blobs within the container via anonymous request, but cannot enumerate containers within the storage account.
|
215
216
|
|
216
|
-
-
|
217
|
+
- ###### Blob
|
217
218
|
|
218
219
|
Public read access for blobs only. Blob data within this container can be read via anonymous request, but container data is not available. Clients cannot enumerate blobs within the container via anonymous request.
|
219
220
|
|
220
|
-
-
|
221
|
+
- ###### Nil
|
221
222
|
|
222
223
|
No public read access. Container and blob data can be read by the account owner only.
|
223
224
|
|
224
225
|
```ruby
|
225
|
-
directory =
|
226
|
-
directory.acl = '
|
227
|
-
directory.save(is_create:
|
226
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
227
|
+
directory.acl = '<Container Name>'
|
228
|
+
directory.save(is_create: <True/False>)
|
228
229
|
```
|
229
230
|
|
230
231
|
## Delete the storage container
|
@@ -232,13 +233,13 @@ directory.save(is_create: false)
|
|
232
233
|
Mark the specified container for deletion. The container and any blobs contained within it are later deleted during garbage collection.
|
233
234
|
|
234
235
|
```ruby
|
235
|
-
directory =
|
236
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
236
237
|
puts directory.destroy
|
237
238
|
```
|
238
239
|
|
239
240
|
## Upload data as a block blob
|
240
241
|
```ruby
|
241
|
-
directory =
|
242
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
242
243
|
options = {
|
243
244
|
key: '<Blob Name>',
|
244
245
|
body: '<Blob Content>'
|
@@ -249,7 +250,7 @@ puts new_block_blob.inspect
|
|
249
250
|
|
250
251
|
## Upload a local file as a block blob
|
251
252
|
```ruby
|
252
|
-
directory =
|
253
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
253
254
|
File.open('<File Path>') do |file|
|
254
255
|
options = {
|
255
256
|
key: '<Blob Name>',
|
@@ -262,11 +263,11 @@ end
|
|
262
263
|
|
263
264
|
## Upload VHD data as a page blob
|
264
265
|
```ruby
|
265
|
-
directory =
|
266
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
266
267
|
options = {
|
267
268
|
key: '<Blob Name>',
|
268
269
|
body: '<Blob Content>',
|
269
|
-
blob_type: '
|
270
|
+
blob_type: '<Blob Type>'
|
270
271
|
}
|
271
272
|
new_page_blob = directory.files.create(options)
|
272
273
|
puts new_page_blob.inspect
|
@@ -274,12 +275,12 @@ puts new_page_blob.inspect
|
|
274
275
|
|
275
276
|
## Upload a local VHD as a page blob
|
276
277
|
```ruby
|
277
|
-
directory =
|
278
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
278
279
|
File.open('<File Path>') do |file|
|
279
280
|
options = {
|
280
281
|
key: '<Blob Name>',
|
281
282
|
body: file,
|
282
|
-
blob_type: '
|
283
|
+
blob_type: '<Blob Type>'
|
283
284
|
}
|
284
285
|
new_page_blob = directory.files.create(options)
|
285
286
|
puts new_page_blob.inspect
|
@@ -288,14 +289,14 @@ end
|
|
288
289
|
|
289
290
|
## Copy Blob from one container to another
|
290
291
|
```ruby
|
291
|
-
directory =
|
292
|
+
directory = fog_storage_service.directories.get('<Source Container Name>', max_keys: <Maximum No. of Keys Value>)
|
292
293
|
copied_blob = directory.files.head('<Source Blob Name>').copy('<Destination Container Name>', '<Destination Blob Name>')
|
293
294
|
puts copied_blob.inspect
|
294
295
|
```
|
295
296
|
|
296
297
|
## Copy Blob from one uri to self
|
297
298
|
```ruby
|
298
|
-
directory =
|
299
|
+
directory = fog_storage_service.directories.get('<Destination Container Name>', max_keys: <Maximum No. of Keys Value>)
|
299
300
|
copied_blob = directory.files.new(key: '<Destination Blob Name>')
|
300
301
|
copied_blob.copy_from_uri('<Source Blob Uri>')
|
301
302
|
puts copied_blob.inspect
|
@@ -303,7 +304,7 @@ puts copied_blob.inspect
|
|
303
304
|
|
304
305
|
## Download a small blob to a local file
|
305
306
|
```ruby
|
306
|
-
directory =
|
307
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
307
308
|
blob = directory.files.get('<Blob Name>')
|
308
309
|
File.open('<File Path>', 'wb') do |file|
|
309
310
|
file.write(blob.body)
|
@@ -313,7 +314,7 @@ puts "File Size: #{::File.size <File Path>}"
|
|
313
314
|
|
314
315
|
## Download a large blob to a local file
|
315
316
|
```ruby
|
316
|
-
directory =
|
317
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
317
318
|
File.open('<File Path>', 'wb') do |file|
|
318
319
|
directory.files.get('<Blob Name>') do |chunk, remaining_bytes, total_bytes|
|
319
320
|
puts "remaining_bytes: #{remaining_bytes}, total_bytes: #{total_bytes}"
|
@@ -328,21 +329,21 @@ puts "File Size: #{::File.size <File Path>}"
|
|
328
329
|
Mark the specified blob for deletion. The blob is later deleted during garbage collection.
|
329
330
|
|
330
331
|
```ruby
|
331
|
-
directory =
|
332
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
332
333
|
blob = directory.files.head('<Blob Name>')
|
333
334
|
puts blob.destroy
|
334
335
|
```
|
335
336
|
|
336
|
-
|
337
|
+
## Set storage blob properties
|
337
338
|
|
338
339
|
Set the storage blob properties.
|
339
340
|
|
340
341
|
```ruby
|
341
|
-
directory =
|
342
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
342
343
|
blob = directory.files.head('<Blob Name>')
|
343
|
-
blob.content_language =
|
344
|
-
blob.content_disposition =
|
345
|
-
blob.save(update_body:
|
344
|
+
blob.content_language = '<Language>'
|
345
|
+
blob.content_disposition = '<Content Disposition Type>'
|
346
|
+
blob.save(update_body: <True/False>)
|
346
347
|
```
|
347
348
|
|
348
349
|
## Metadata
|
@@ -352,7 +353,7 @@ Metadata allows us to provide descriptive information about specific containers
|
|
352
353
|
### Get Blob Metadata
|
353
354
|
|
354
355
|
```ruby
|
355
|
-
directory =
|
356
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
356
357
|
blob = directory.files.head('<Blob Name>')
|
357
358
|
puts blob.metadata
|
358
359
|
```
|
@@ -360,101 +361,35 @@ puts blob.metadata
|
|
360
361
|
### Set Blob Metadata
|
361
362
|
|
362
363
|
```ruby
|
363
|
-
directory =
|
364
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
364
365
|
blob = directory.files.head('<Blob Name>')
|
365
366
|
blob.metadata = {
|
366
|
-
|
367
|
-
|
367
|
+
Category: '<Category Value>',
|
368
|
+
Resolution: '<Resolution Value>'
|
368
369
|
}
|
369
|
-
blob.save(update_body:
|
370
|
+
blob.save(update_body: <True/False>)
|
370
371
|
```
|
371
372
|
|
372
373
|
### Get Container Metadata
|
373
374
|
|
374
375
|
```ruby
|
375
|
-
directory =
|
376
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
376
377
|
puts directory.metadata
|
377
378
|
```
|
378
379
|
|
379
380
|
### Set Container Metadata
|
380
381
|
|
381
382
|
```ruby
|
382
|
-
directory =
|
383
|
+
directory = fog_storage_service.directories.get('<Container Name>', max_keys: <Maximum No. of Keys Value>)
|
383
384
|
directory.metadata = {
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
directory.save(is_create:
|
390
|
-
```
|
391
|
-
|
392
|
-
### Create Recovery Vault
|
393
|
-
|
394
|
-
Create a new Recovery Vault object
|
395
|
-
|
396
|
-
```ruby
|
397
|
-
azure_storage_service.recovery_vaults.create(
|
398
|
-
name: '<vault_name>',
|
399
|
-
location: '<location>',
|
400
|
-
resource_group: '<resource_group_name>'
|
401
|
-
```
|
402
|
-
|
403
|
-
### Get Recovery Vault
|
404
|
-
|
405
|
-
Retrieves a Recovery Vault object
|
406
|
-
|
407
|
-
```ruby
|
408
|
-
recovery_vault = azure_storage_service.recovery_vaults.get(
|
409
|
-
'Vault Name',
|
410
|
-
'Vault Resource Group'
|
411
|
-
)
|
412
|
-
```
|
413
|
-
|
414
|
-
### List Recovery Vaults
|
415
|
-
|
416
|
-
List the Recovery Vaults in a resource group
|
417
|
-
|
418
|
-
```ruby
|
419
|
-
azure_storage_service.recovery_vaults('Resource Group Name').each do |recovery_vault|
|
420
|
-
puts recovery_vault.inspect
|
421
|
-
end
|
422
|
-
```
|
423
|
-
|
424
|
-
### Enable Backup Protection
|
425
|
-
|
426
|
-
Enables backup protection for a virtual machine in the recovery vault. Backup protection for a virtual machine must be enabled before running backup.
|
427
|
-
|
428
|
-
```ruby
|
429
|
-
recovery_vault.enable_backup_protection('Virtual Machine Name', 'Virtual Machine Resource Group')
|
430
|
-
```
|
431
|
-
|
432
|
-
### Disable Backup Protection
|
433
|
-
|
434
|
-
Disables backup protection for a virtual machine in the recovery vault.
|
435
|
-
|
436
|
-
```ruby
|
437
|
-
recovery_vault.disable_backup_protection('Virtual Machine Name', 'Virtual Machine Resource Group')
|
438
|
-
```
|
439
|
-
|
440
|
-
### Start Backup
|
441
|
-
|
442
|
-
Starts the backup process for a given virtual machine
|
443
|
-
|
444
|
-
```ruby
|
445
|
-
recovery_vault.start_backup('Virtual Machine Name', 'Virtual Machine Resource Group')
|
446
|
-
```
|
447
|
-
|
448
|
-
### Destroy Recovery Vault
|
449
|
-
|
450
|
-
Destroys the Recovery Vault
|
451
|
-
|
452
|
-
```ruby
|
453
|
-
recovery_vault.destroy
|
385
|
+
CreatedBy: '<Username>',
|
386
|
+
SourceMachine: '<Machine Name>',
|
387
|
+
category: '<Category Value>',
|
388
|
+
docType: '<Document Type>'
|
389
|
+
}
|
390
|
+
directory.save(is_create: <True/False>)
|
454
391
|
```
|
455
392
|
|
456
|
-
Note that a Recovery Vault must not contain any backup protectable items or tasks running in order for you to delete it. If any item is present, it must be deleted from the portal first before running this command.
|
457
|
-
|
458
393
|
## Support and Feedback
|
459
394
|
Your feedback is appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.
|
460
395
|
|