fog-azure-rm 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -1
- data/CHANGELOG.md +8 -0
- data/lib/fog/azurerm/async_response.rb +6 -1
- data/lib/fog/azurerm/docs/application_gateway.md +119 -116
- data/lib/fog/azurerm/docs/compute.md +219 -217
- data/lib/fog/azurerm/docs/dns.md +43 -45
- data/lib/fog/azurerm/docs/key_vault.md +31 -31
- data/lib/fog/azurerm/docs/network.md +403 -405
- data/lib/fog/azurerm/docs/resources.md +51 -51
- data/lib/fog/azurerm/docs/sql.md +51 -51
- data/lib/fog/azurerm/docs/storage.md +89 -88
- data/lib/fog/azurerm/docs/traffic_manager.md +55 -54
- data/lib/fog/azurerm/models/compute/server.rb +6 -0
- data/lib/fog/azurerm/models/compute/servers.rb +1 -1
- data/lib/fog/azurerm/requests/compute/get_virtual_machine.rb +4 -2
- data/lib/fog/azurerm/version.rb +1 -1
- data/rake-script.sh +7 -1
- data/rakefile +1 -1
- data/test/api_stub/models/compute/server.rb +16 -0
- data/test/models/compute/test_server.rb +7 -3
- metadata +3 -3
@@ -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
|
-
tenant_id: '<
|
20
|
-
client_id: '<
|
21
|
-
client_secret: '<
|
22
|
-
subscription_id: '<
|
23
|
-
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>'
|
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,19 +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
40
|
location: '<Location>',
|
41
|
-
tags:
|
42
|
-
|
41
|
+
tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional]
|
42
|
+
)
|
43
43
|
```
|
44
44
|
## List Resource Groups
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
|
47
|
+
fog_resources_service.resource_groups.each do |resource_group|
|
48
48
|
puts "#{resource_group.name}"
|
49
49
|
puts "#{resource_group.location}"
|
50
|
-
|
50
|
+
end
|
51
51
|
```
|
52
52
|
|
53
53
|
## Retrieve a single Resource Group
|
@@ -55,10 +55,10 @@ Create a new resource group
|
|
55
55
|
Get a single record of Resource Group
|
56
56
|
|
57
57
|
```ruby
|
58
|
-
|
58
|
+
resource_group = fog_resources_service
|
59
59
|
.resource_groups
|
60
|
-
.get('<Resource Group
|
61
|
-
|
60
|
+
.get('<Resource Group Name>')
|
61
|
+
puts "#{resource_group.name}"
|
62
62
|
```
|
63
63
|
|
64
64
|
## Destroy a single Resource Group
|
@@ -66,71 +66,71 @@ Get a single record of Resource Group
|
|
66
66
|
Get resource group object from the get method(described above) and then destroy that resource group.
|
67
67
|
|
68
68
|
```ruby
|
69
|
-
|
69
|
+
resource_group.destroy
|
70
70
|
```
|
71
71
|
## Tagging a Resource
|
72
72
|
|
73
73
|
You can tag a Resource as following:
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
|
77
|
-
'<Resource
|
78
|
-
'<Tag
|
79
|
-
'<Tag
|
80
|
-
'<API
|
81
|
-
|
76
|
+
fog_resources_service.tag_resource(
|
77
|
+
'<Resource Id>',
|
78
|
+
'<Tag Key>',
|
79
|
+
'<Tag Value>',
|
80
|
+
'<API Version>'
|
81
|
+
)
|
82
82
|
```
|
83
83
|
|
84
84
|
## List Tagged Resources in a Subscription
|
85
85
|
|
86
86
|
```ruby
|
87
|
-
|
87
|
+
fog_resources_service.azure_resources(tag_name: '<Tag Key>', tag_value: '<Tag Value>').each do |resource|
|
88
88
|
puts "#{resource.name}"
|
89
89
|
puts "#{resource.location}"
|
90
90
|
puts "#{resource.type}"
|
91
|
-
|
91
|
+
end
|
92
92
|
```
|
93
93
|
OR
|
94
94
|
```ruby
|
95
|
-
|
95
|
+
fog_resources_service.azure_resources(tag_name: '<Tag Key>').each do |resource|
|
96
96
|
puts "#{resource.name}"
|
97
97
|
puts "#{resource.location}"
|
98
98
|
puts "#{resource.type}"
|
99
|
-
|
99
|
+
end
|
100
100
|
```
|
101
101
|
## Retrieve a single Resource
|
102
102
|
|
103
103
|
Get a single record of Tagged Resources
|
104
104
|
|
105
105
|
```ruby
|
106
|
-
|
107
|
-
.azure_resources(tag_name: '<Tag
|
108
|
-
.get('<Resource
|
109
|
-
|
106
|
+
resource = fog_resources_service
|
107
|
+
.azure_resources(tag_name: '<Tag Key>')
|
108
|
+
.get('<Resource Id>')
|
109
|
+
puts "#{resource.name}"
|
110
110
|
```
|
111
111
|
## Remove tag from a Resource
|
112
112
|
|
113
113
|
Remove tag from a resource as following:
|
114
114
|
|
115
115
|
```ruby
|
116
|
-
|
117
|
-
'<Resource
|
118
|
-
'<Tag
|
119
|
-
'<Tag
|
120
|
-
'<API
|
121
|
-
|
116
|
+
fog_resources_service.delete_resource_tag(
|
117
|
+
'<Resource Id>',
|
118
|
+
'<Tag Key>',
|
119
|
+
'<Tag Value>',
|
120
|
+
'<API Version>'
|
121
|
+
)
|
122
122
|
```
|
123
123
|
|
124
124
|
## Check Resource Existence
|
125
125
|
|
126
126
|
```ruby
|
127
|
-
|
127
|
+
fog_resources_service.azure_resources.check_azure_resource_exists('<Resource Id>', '<API Version>')
|
128
128
|
```
|
129
129
|
|
130
130
|
## Check Deployment Existence
|
131
131
|
|
132
132
|
```ruby
|
133
|
-
|
133
|
+
fog_resources_service.deployments.check_deployment_exists('<Resource Group Name>', '<Deployment Name>')
|
134
134
|
```
|
135
135
|
|
136
136
|
## Create Deployment
|
@@ -138,21 +138,21 @@ Remove tag from a resource as following:
|
|
138
138
|
Create a Deployment
|
139
139
|
|
140
140
|
```ruby
|
141
|
-
|
142
|
-
name: '<Deployment
|
143
|
-
resource_group: '<Resource Group
|
141
|
+
fog_resources_service.deployments.create(
|
142
|
+
name: '<Deployment Name>',
|
143
|
+
resource_group: '<Resource Group Name>',
|
144
144
|
template_link: '<Template Link>',
|
145
145
|
parameters_link: '<Parameters Link>'
|
146
|
-
|
146
|
+
)
|
147
147
|
```
|
148
148
|
## List Deployments
|
149
149
|
|
150
150
|
List Deployments in a resource group
|
151
151
|
|
152
152
|
```ruby
|
153
|
-
|
153
|
+
fog_resources_service.deployments(resource_group: '<Resource Group Name>').each do |deployment|
|
154
154
|
puts "#{deployment.name}"
|
155
|
-
|
155
|
+
end
|
156
156
|
```
|
157
157
|
|
158
158
|
## Retrieve a single Deployment
|
@@ -160,10 +160,10 @@ List Deployments in a resource group
|
|
160
160
|
Get a single record of Deployment
|
161
161
|
|
162
162
|
```ruby
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
163
|
+
deployment = fog_resources_service
|
164
|
+
.deployments
|
165
|
+
.get('<Resource Group Name>', '<Deployment Name>')
|
166
|
+
puts "#{deployment.name}"
|
167
167
|
```
|
168
168
|
|
169
169
|
## Destroy a single Deployment
|
@@ -171,7 +171,7 @@ Get a single record of Deployment
|
|
171
171
|
Get Deployment object from the get method(described above) and then destroy that Deployment.
|
172
172
|
|
173
173
|
```ruby
|
174
|
-
|
174
|
+
deployment.destroy
|
175
175
|
```
|
176
176
|
|
177
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
|
-
tenant_id: '<
|
20
|
-
client_id: '<
|
21
|
-
client_secret: '<
|
22
|
-
subscription_id: '<
|
23
|
-
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>'
|
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,25 +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
|
-
tags: { key1:
|
43
|
-
|
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
|
+
)
|
44
44
|
```
|
45
45
|
For more information, see link: https://msdn.microsoft.com/en-us/library/azure/mt297738.aspx
|
46
46
|
|
47
47
|
## List SQL Servers
|
48
48
|
Get a list of servers in given resource group
|
49
49
|
```ruby
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
servers = fog_sql_service.sql_servers(resource_group: '<Resource Group Name>')
|
51
|
+
servers.each do |server|
|
52
|
+
puts "Listing : #{server.name}"
|
53
|
+
end
|
54
54
|
```
|
55
55
|
|
56
56
|
## Retrieve a single SQL Server
|
@@ -58,9 +58,9 @@ Get a list of servers in given resource group
|
|
58
58
|
Get a single record of SQL Server
|
59
59
|
|
60
60
|
```ruby
|
61
|
-
|
62
|
-
|
63
|
-
|
61
|
+
server = fog_sql_service.sql_servers
|
62
|
+
.get('<Resource Group Name>', '<Server Name>')
|
63
|
+
puts "Server Name: #{server.name}"
|
64
64
|
```
|
65
65
|
|
66
66
|
## Destroy a SQL Server
|
@@ -68,33 +68,33 @@ Get a single record of SQL Server
|
|
68
68
|
Get SQL Server object from the get method(described above) and destroy that Server.
|
69
69
|
|
70
70
|
```ruby
|
71
|
-
|
71
|
+
server.destroy
|
72
72
|
```
|
73
73
|
|
74
74
|
## Create SQL Database
|
75
75
|
|
76
76
|
Creates a new Sql Database
|
77
77
|
|
78
|
-
In parameter
|
78
|
+
In parameter _create_mode_: 'Copy', 'NonReadableSecondary', and 'OnlineSecondary' are not supported by SQL Data Warehouse.
|
79
79
|
|
80
|
-
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']
|
81
81
|
|
82
82
|
```ruby
|
83
|
-
|
83
|
+
fog_sql_service.sql_databases.create(
|
84
84
|
resource_group: '<Resource Group Name>',
|
85
|
-
location: '
|
85
|
+
location: '<Location>',
|
86
86
|
server_name: '<Server Name>',
|
87
87
|
name: '<Database Name>',
|
88
|
-
|
89
|
-
edition: '<Edition>', # 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]
|
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]
|
90
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.
|
91
90
|
collation: '<Collation>', # Conditional. Specifies the name of the collation. If createMode is set to Default, then this value must be specified.
|
92
|
-
max_size_bytes: '<Size>',
|
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.
|
93
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]
|
94
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.
|
95
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.
|
96
|
-
tags: { key1:
|
97
|
-
|
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
|
+
)
|
98
98
|
```
|
99
99
|
For more information see link: https://msdn.microsoft.com/en-us/library/azure/mt163685.aspx
|
100
100
|
|
@@ -102,10 +102,10 @@ For more information see link: https://msdn.microsoft.com/en-us/library/azure/mt
|
|
102
102
|
Get a list of databases in given resource group
|
103
103
|
|
104
104
|
```ruby
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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
|
109
109
|
```
|
110
110
|
|
111
111
|
## Retrieve a single SQL Database
|
@@ -113,17 +113,17 @@ Get a list of databases in given resource group
|
|
113
113
|
Get a single record of SQL Database
|
114
114
|
|
115
115
|
```ruby
|
116
|
-
|
117
|
-
|
118
|
-
|
116
|
+
database = fog_sql_service.sql_databases
|
117
|
+
.get('<Resource Group Name>', '<Server Name>', '<Database Name>')
|
118
|
+
puts "Database Name: #{database.name}"
|
119
119
|
```
|
120
120
|
|
121
|
-
## Destroy a SQL Database
|
121
|
+
## Destroy a single SQL Database
|
122
122
|
|
123
123
|
Get SQL Database object from the get method(described above) and destroy that Database.
|
124
124
|
|
125
125
|
```ruby
|
126
|
-
|
126
|
+
database.destroy
|
127
127
|
```
|
128
128
|
|
129
129
|
## Create Firewall Rule
|
@@ -131,38 +131,38 @@ Get SQL Database object from the get method(described above) and destroy that Da
|
|
131
131
|
Create a new Firewall Rule
|
132
132
|
|
133
133
|
```ruby
|
134
|
-
|
134
|
+
fog_sql_service.firewall_rules.create(
|
135
135
|
name: '<Firewall Rule Name>',
|
136
136
|
resource_group: '<Resource Group Name>',
|
137
137
|
server_location: '<Server Name>',
|
138
138
|
start_ip: '<Start IP Address>', # Specifies the starting IP address to allow through the firewall.
|
139
139
|
end_ip: '<End IP Address>', # Specifies the ending IP address to allow through the firewall.
|
140
140
|
|
141
|
-
|
141
|
+
)
|
142
142
|
```
|
143
143
|
|
144
144
|
## List Firewall Rules
|
145
145
|
Get a list of Firewall Rules on a SQL Server in given resource group
|
146
146
|
```ruby
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
151
151
|
```
|
152
152
|
|
153
153
|
## Retrieve a single Firewall Rule
|
154
154
|
Get a single record of Firewall rule on SQL Server
|
155
155
|
```ruby
|
156
|
-
|
156
|
+
firewall_rule = fog_sql_service.firewall_rules
|
157
157
|
.get('<Resource Group Name>', '<Server Name>', '<Firewall Rule Name>')
|
158
|
-
|
158
|
+
puts "Get: Firewall Rule Name: #{firewall_rule.name}"
|
159
159
|
```
|
160
160
|
|
161
161
|
## Destroy a Firewall Rule
|
162
162
|
Get Firewall Rule object from the get method(described above) and destroy that Firewall Rule.
|
163
163
|
|
164
164
|
```ruby
|
165
|
-
|
165
|
+
firewall_rule.destroy
|
166
166
|
```
|
167
167
|
|
168
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
|
-
tenant_id: '<
|
20
|
-
client_id: '<
|
21
|
-
client_secret: '<
|
22
|
-
subscription_id: '<
|
23
|
-
azure_storage_account_name: '<
|
24
|
-
azure_storage_access_key: '<
|
25
|
-
environment: '<AzureCloud/AzureChinaCloud/AzureUSGovernment/AzureGermanCloud>'
|
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.
|
26
26
|
)
|
27
27
|
```
|
28
28
|
|
29
29
|
If you only want to manage the storage accounts, you can create the connection without the storage account information:
|
30
30
|
|
31
31
|
```ruby
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
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.
|
39
38
|
)
|
40
39
|
```
|
41
40
|
|
42
41
|
If you only want to manage the storage data, you can create the connection without the Azure subscription information:
|
43
42
|
|
44
43
|
```ruby
|
45
|
-
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
: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.
|
50
48
|
)
|
51
49
|
```
|
52
50
|
|
53
51
|
## Check Name Availability
|
54
52
|
|
55
|
-
|
56
|
-
_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
|
57
54
|
|
58
55
|
```ruby
|
59
|
-
|
56
|
+
fog_storage_service.storage_accounts.check_name_availability('<Storage Account Name>', '<Storage Account Type>')
|
60
57
|
```
|
61
58
|
|
62
59
|
## Check Storage Account Existence
|
63
60
|
|
64
61
|
```ruby
|
65
|
-
|
62
|
+
fog_storage_service.storage_accounts.check_storage_account_exists('<Resource Group Name>', '<Storage Account Name>')
|
66
63
|
```
|
67
64
|
|
68
65
|
## Create Storage Account
|
69
66
|
|
70
67
|
Create a new storage account. Replication attribute for Standard and Premium account types are as follows
|
71
68
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
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)
|
77
78
|
|
78
79
|
```ruby
|
79
|
-
|
80
|
+
fog_storage_service.storage_accounts.create(
|
80
81
|
name: '<Storage Account name>',
|
81
82
|
location: '<Location>',
|
82
|
-
resource_group: '<Resource Group
|
83
|
+
resource_group: '<Resource Group Name>',
|
83
84
|
account_type: '<Standard/Premium>', # [Optional] Default value 'Standard'. Allowed values can only be Standard or Premium
|
84
|
-
replication: '
|
85
|
-
encryption:
|
86
|
-
tags: { key1:
|
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,33 +361,33 @@ 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:
|
385
|
+
CreatedBy: '<Username>',
|
386
|
+
SourceMachine: '<Machine Name>',
|
387
|
+
category: '<Category Value>',
|
388
|
+
docType: '<Document Type>'
|
389
|
+
}
|
390
|
+
directory.save(is_create: <True/False>)
|
390
391
|
```
|
391
392
|
|
392
393
|
## Support and Feedback
|