azure-fix 0.7.0.pre3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (311) hide show
  1. checksums.yaml +7 -0
  2. data/.env_sample +13 -0
  3. data/.gitignore +30 -0
  4. data/.travis.yml +13 -0
  5. data/ChangeLog.txt +56 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE.txt +202 -0
  8. data/README.md +702 -0
  9. data/Rakefile +121 -0
  10. data/azure.gemspec +51 -0
  11. data/bin/pfxer +35 -0
  12. data/lib/azure.rb +147 -0
  13. data/lib/azure/base_management/affinity_group.rb +32 -0
  14. data/lib/azure/base_management/base_management_service.rb +220 -0
  15. data/lib/azure/base_management/location.rb +27 -0
  16. data/lib/azure/base_management/management_http_request.rb +172 -0
  17. data/lib/azure/base_management/serialization.rb +135 -0
  18. data/lib/azure/base_management/sql_management_http_request.rb +35 -0
  19. data/lib/azure/blob/auth/shared_access_signature.rb +147 -0
  20. data/lib/azure/blob/blob.rb +32 -0
  21. data/lib/azure/blob/blob_service.rb +1452 -0
  22. data/lib/azure/blob/block.rb +31 -0
  23. data/lib/azure/blob/container.rb +32 -0
  24. data/lib/azure/blob/serialization.rb +285 -0
  25. data/lib/azure/client.rb +31 -0
  26. data/lib/azure/client_services.rb +98 -0
  27. data/lib/azure/cloud_service_management/cloud_service.rb +38 -0
  28. data/lib/azure/cloud_service_management/cloud_service_management_service.rb +135 -0
  29. data/lib/azure/cloud_service_management/serialization.rb +118 -0
  30. data/lib/azure/configurable.rb +290 -0
  31. data/lib/azure/core/auth/authorizer.rb +36 -0
  32. data/lib/azure/core/auth/shared_key.rb +118 -0
  33. data/lib/azure/core/auth/shared_key_lite.rb +48 -0
  34. data/lib/azure/core/auth/signer.rb +51 -0
  35. data/lib/azure/core/error.rb +21 -0
  36. data/lib/azure/core/filtered_service.rb +45 -0
  37. data/lib/azure/core/http/debug_filter.rb +36 -0
  38. data/lib/azure/core/http/http_error.rb +86 -0
  39. data/lib/azure/core/http/http_filter.rb +53 -0
  40. data/lib/azure/core/http/http_request.rb +173 -0
  41. data/lib/azure/core/http/http_response.rb +96 -0
  42. data/lib/azure/core/http/retry_policy.rb +74 -0
  43. data/lib/azure/core/http/signer_filter.rb +33 -0
  44. data/lib/azure/core/service.rb +46 -0
  45. data/lib/azure/core/signed_service.rb +45 -0
  46. data/lib/azure/core/utility.rb +244 -0
  47. data/lib/azure/default.rb +126 -0
  48. data/lib/azure/http_client.rb +85 -0
  49. data/lib/azure/queue/message.rb +30 -0
  50. data/lib/azure/queue/queue.rb +28 -0
  51. data/lib/azure/queue/queue_service.rb +570 -0
  52. data/lib/azure/queue/serialization.rb +105 -0
  53. data/lib/azure/service/access_policy.rb +26 -0
  54. data/lib/azure/service/cors.rb +11 -0
  55. data/lib/azure/service/cors_rule.rb +15 -0
  56. data/lib/azure/service/enumeration_results.rb +21 -0
  57. data/lib/azure/service/logging.rb +32 -0
  58. data/lib/azure/service/metrics.rb +31 -0
  59. data/lib/azure/service/retention_policy.rb +25 -0
  60. data/lib/azure/service/serialization.rb +299 -0
  61. data/lib/azure/service/signed_identifier.rb +30 -0
  62. data/lib/azure/service/storage_service.rb +86 -0
  63. data/lib/azure/service/storage_service_properties.rb +37 -0
  64. data/lib/azure/service_bus/action.rb +21 -0
  65. data/lib/azure/service_bus/auth/shared_access_signer.rb +44 -0
  66. data/lib/azure/service_bus/auth/wrap_service.rb +90 -0
  67. data/lib/azure/service_bus/auth/wrap_signer.rb +77 -0
  68. data/lib/azure/service_bus/brokered_message.rb +124 -0
  69. data/lib/azure/service_bus/brokered_message_serializer.rb +159 -0
  70. data/lib/azure/service_bus/correlation_filter.rb +45 -0
  71. data/lib/azure/service_bus/empty_rule_action.rb +30 -0
  72. data/lib/azure/service_bus/false_filter.rb +38 -0
  73. data/lib/azure/service_bus/filter.rb +21 -0
  74. data/lib/azure/service_bus/interval.rb +104 -0
  75. data/lib/azure/service_bus/queue.rb +230 -0
  76. data/lib/azure/service_bus/relay.rb +88 -0
  77. data/lib/azure/service_bus/resource.rb +109 -0
  78. data/lib/azure/service_bus/rule.rb +98 -0
  79. data/lib/azure/service_bus/rule_aspect.rb +34 -0
  80. data/lib/azure/service_bus/serialization.rb +161 -0
  81. data/lib/azure/service_bus/service_bus_service.rb +899 -0
  82. data/lib/azure/service_bus/sql_filter.rb +50 -0
  83. data/lib/azure/service_bus/sql_rule_action.rb +50 -0
  84. data/lib/azure/service_bus/subscription.rb +184 -0
  85. data/lib/azure/service_bus/topic.rb +187 -0
  86. data/lib/azure/service_bus/true_filter.rb +38 -0
  87. data/lib/azure/sql_database_management/errors.rb +11 -0
  88. data/lib/azure/sql_database_management/firewall_rule.rb +30 -0
  89. data/lib/azure/sql_database_management/serialization.rb +99 -0
  90. data/lib/azure/sql_database_management/sql_database_management_service.rb +211 -0
  91. data/lib/azure/sql_database_management/sql_server.rb +32 -0
  92. data/lib/azure/storage_management/serialization.rb +204 -0
  93. data/lib/azure/storage_management/storage_account.rb +48 -0
  94. data/lib/azure/storage_management/storage_management_service.rb +207 -0
  95. data/lib/azure/table/auth/shared_key.rb +59 -0
  96. data/lib/azure/table/auth/shared_key_lite.rb +44 -0
  97. data/lib/azure/table/batch.rb +330 -0
  98. data/lib/azure/table/batch_response.rb +118 -0
  99. data/lib/azure/table/edmtype.rb +127 -0
  100. data/lib/azure/table/entity.rb +31 -0
  101. data/lib/azure/table/guid.rb +24 -0
  102. data/lib/azure/table/query.rb +112 -0
  103. data/lib/azure/table/serialization.rb +108 -0
  104. data/lib/azure/table/table_service.rb +563 -0
  105. data/lib/azure/version.rb +31 -0
  106. data/lib/azure/virtual_machine_image_management/serialization.rb +70 -0
  107. data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +25 -0
  108. data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +25 -0
  109. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +83 -0
  110. data/lib/azure/virtual_machine_management/serialization.rb +459 -0
  111. data/lib/azure/virtual_machine_management/virtual_machine.rb +44 -0
  112. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +552 -0
  113. data/lib/azure/virtual_network_management/serialization.rb +193 -0
  114. data/lib/azure/virtual_network_management/virtual_network.rb +37 -0
  115. data/lib/azure/virtual_network_management/virtual_network_management_service.rb +108 -0
  116. data/test/fixtures/32px-fulls-black.jpg +0 -0
  117. data/test/fixtures/affinity_group.xml +33 -0
  118. data/test/fixtures/all_containers.xml +20 -0
  119. data/test/fixtures/all_tables.xml +22 -0
  120. data/test/fixtures/container_acl.xml +11 -0
  121. data/test/fixtures/create_sql_database_server.xml +2 -0
  122. data/test/fixtures/create_storage_desc_error.xml +5 -0
  123. data/test/fixtures/create_storage_extendedprop_error.xml +8 -0
  124. data/test/fixtures/create_storage_extendedpropname_error.xml +6 -0
  125. data/test/fixtures/create_storage_full_error.xml +6 -0
  126. data/test/fixtures/create_storage_label_error.xml +5 -0
  127. data/test/fixtures/create_storage_location_error.xml +5 -0
  128. data/test/fixtures/create_storage_name_error.xml +6 -0
  129. data/test/fixtures/create_table_response_entry.xml +15 -0
  130. data/test/fixtures/delete_storage_container_error.xml +5 -0
  131. data/test/fixtures/delete_storage_error.xml +5 -0
  132. data/test/fixtures/deployment_error.xml +5 -0
  133. data/test/fixtures/empty_xml_file +0 -0
  134. data/test/fixtures/get_storage_account_error.xml +5 -0
  135. data/test/fixtures/get_storage_account_properties.xml +34 -0
  136. data/test/fixtures/get_storage_account_properties_new.xml +32 -0
  137. data/test/fixtures/http_error.xml +5 -0
  138. data/test/fixtures/insert_entity_response_entry.xml +25 -0
  139. data/test/fixtures/list_affinity_groups.xml +22 -0
  140. data/test/fixtures/list_blobs.xml +121 -0
  141. data/test/fixtures/list_block_all_with_none_committed.xml +22 -0
  142. data/test/fixtures/list_blocks_all.xml +23 -0
  143. data/test/fixtures/list_blocks_committed.xml +13 -0
  144. data/test/fixtures/list_cloud_services.xml +39 -0
  145. data/test/fixtures/list_containers.xml +38 -0
  146. data/test/fixtures/list_firewall_management_endpoint.xml +27 -0
  147. data/test/fixtures/list_locations.xml +212 -0
  148. data/test/fixtures/list_os_images.xml +110 -0
  149. data/test/fixtures/list_page_ranges.xml +11 -0
  150. data/test/fixtures/list_sql_database.xml +24 -0
  151. data/test/fixtures/list_sql_server_firewall.xml +23 -0
  152. data/test/fixtures/list_storage_account_single.xml +25 -0
  153. data/test/fixtures/list_storage_accounts.xml +48 -0
  154. data/test/fixtures/list_virtual_networks.xml +92 -0
  155. data/test/fixtures/list_vm_images.xml +21 -0
  156. data/test/fixtures/logging.xml +11 -0
  157. data/test/fixtures/management_certificate.pfx +0 -0
  158. data/test/fixtures/messages.xml +12 -0
  159. data/test/fixtures/metrics.xml +10 -0
  160. data/test/fixtures/privatekey.key +28 -0
  161. data/test/fixtures/query_entities_empty_response.xml +7 -0
  162. data/test/fixtures/query_entities_response.xml +45 -0
  163. data/test/fixtures/queue_service_properties.xml +22 -0
  164. data/test/fixtures/queue_service_properties_original.xml +19 -0
  165. data/test/fixtures/queues.xml +16 -0
  166. data/test/fixtures/retention_policy.xml +5 -0
  167. data/test/fixtures/sb_default_create_queue_response.xml +23 -0
  168. data/test/fixtures/sb_default_create_relay_response.xml +15 -0
  169. data/test/fixtures/sb_default_create_topic_response.xml +18 -0
  170. data/test/fixtures/sb_get_access_token_response.txt +1 -0
  171. data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +9 -0
  172. data/test/fixtures/storage_service_keys.xml +8 -0
  173. data/test/fixtures/storage_service_properties.xml +55 -0
  174. data/test/fixtures/update_storage_account.xml +16 -0
  175. data/test/fixtures/update_storage_error.xml +5 -0
  176. data/test/fixtures/updated_storage_accounts.xml +55 -0
  177. data/test/fixtures/virtual_machine.xml +116 -0
  178. data/test/fixtures/windows_virtual_machine.xml +106 -0
  179. data/test/integration/affinity_group/Affinity_test.rb +55 -0
  180. data/test/integration/affinity_group/Create_Affinity_test.rb +64 -0
  181. data/test/integration/affinity_group/Delete_Affinity_test.rb +56 -0
  182. data/test/integration/affinity_group/List_Affinity_test.rb +41 -0
  183. data/test/integration/affinity_group/Update_Affinity_test.rb +87 -0
  184. data/test/integration/blob/blob_gb18030_test.rb +199 -0
  185. data/test/integration/blob/blob_metadata_test.rb +75 -0
  186. data/test/integration/blob/blob_pages_test.rb +119 -0
  187. data/test/integration/blob/blob_properties_test.rb +77 -0
  188. data/test/integration/blob/block_blob_test.rb +254 -0
  189. data/test/integration/blob/container/container_acl_test.rb +69 -0
  190. data/test/integration/blob/container/container_metadata_test.rb +50 -0
  191. data/test/integration/blob/container/create_container_test.rb +60 -0
  192. data/test/integration/blob/container/delete_container_test.rb +39 -0
  193. data/test/integration/blob/container/get_container_properties_test.rb +48 -0
  194. data/test/integration/blob/container/list_containers_test.rb +79 -0
  195. data/test/integration/blob/container/root_container_test.rb +55 -0
  196. data/test/integration/blob/copy_blob_test.rb +113 -0
  197. data/test/integration/blob/create_blob_snapshot_test.rb +80 -0
  198. data/test/integration/blob/create_page_blob_test.rb +83 -0
  199. data/test/integration/blob/delete_blob_test.rb +159 -0
  200. data/test/integration/blob/get_blob_test.rb +65 -0
  201. data/test/integration/blob/informative_errors_test.rb +39 -0
  202. data/test/integration/blob/lease/acquire_lease_test.rb +36 -0
  203. data/test/integration/blob/lease/break_lease_test.rb +40 -0
  204. data/test/integration/blob/lease/release_lease_test.rb +40 -0
  205. data/test/integration/blob/lease/renew_lease_test.rb +42 -0
  206. data/test/integration/blob/list_blobs_test.rb +113 -0
  207. data/test/integration/cloud_service/Cloud_Create_test.rb +45 -0
  208. data/test/integration/cloud_service/Cloud_Delete_test.rb +45 -0
  209. data/test/integration/database/create_sql_server_firewall_test.rb +81 -0
  210. data/test/integration/database/create_sql_server_test.rb +53 -0
  211. data/test/integration/database/delete_sql_server_firewall_test.rb +64 -0
  212. data/test/integration/database/delete_sql_server_test.rb +45 -0
  213. data/test/integration/database/list_sql_server_firewall_test.rb +44 -0
  214. data/test/integration/database/list_sql_servers_test.rb +44 -0
  215. data/test/integration/database/reset_password_sql_server_test.rb +53 -0
  216. data/test/integration/location/Location_List_test.rb +39 -0
  217. data/test/integration/location/RoleSize_List_test.rb +35 -0
  218. data/test/integration/queue/clear_messages_test.rb +42 -0
  219. data/test/integration/queue/create_message_test.rb +75 -0
  220. data/test/integration/queue/create_queue_test.rb +50 -0
  221. data/test/integration/queue/delete_message_test.rb +67 -0
  222. data/test/integration/queue/delete_queue_test.rb +45 -0
  223. data/test/integration/queue/informative_errors_test.rb +42 -0
  224. data/test/integration/queue/list_messages_encoded_test.rb +79 -0
  225. data/test/integration/queue/list_messages_test.rb +79 -0
  226. data/test/integration/queue/list_queues_test.rb +43 -0
  227. data/test/integration/queue/peek_messages_test.rb +59 -0
  228. data/test/integration/queue/queue_gb18030_test.rb +131 -0
  229. data/test/integration/queue/queue_metadata_test.rb +40 -0
  230. data/test/integration/queue/update_message_test.rb +74 -0
  231. data/test/integration/service_bus/informative_errors_test.rb +37 -0
  232. data/test/integration/service_bus/queues_scenario_test.rb +200 -0
  233. data/test/integration/service_bus/queues_test.rb +266 -0
  234. data/test/integration/service_bus/relay_test.rb +132 -0
  235. data/test/integration/service_bus/rules_test.rb +145 -0
  236. data/test/integration/service_bus/sb_queue_gb18030_test.rb +182 -0
  237. data/test/integration/service_bus/scenario_test.rb +101 -0
  238. data/test/integration/service_bus/subscriptions_test.rb +211 -0
  239. data/test/integration/service_bus/topics_scenario_test.rb +406 -0
  240. data/test/integration/service_bus/topics_test.rb +129 -0
  241. data/test/integration/storage_management/storage_management_test.rb +185 -0
  242. data/test/integration/table/create_table_test.rb +36 -0
  243. data/test/integration/table/delete_entity_batch_test.rb +107 -0
  244. data/test/integration/table/delete_entity_test.rb +94 -0
  245. data/test/integration/table/delete_table_test.rb +40 -0
  246. data/test/integration/table/get_table_test.rb +37 -0
  247. data/test/integration/table/informative_errors_test.rb +39 -0
  248. data/test/integration/table/insert_entity_batch_test.rb +100 -0
  249. data/test/integration/table/insert_entity_test.rb +88 -0
  250. data/test/integration/table/insert_or_merge_entity_batch_test.rb +159 -0
  251. data/test/integration/table/insert_or_merge_entity_test.rb +143 -0
  252. data/test/integration/table/insert_or_replace_entity_batch_test.rb +152 -0
  253. data/test/integration/table/insert_or_replace_entity_test.rb +137 -0
  254. data/test/integration/table/merge_entity_batch_test.rb +128 -0
  255. data/test/integration/table/merge_entity_test.rb +113 -0
  256. data/test/integration/table/query_entities_test.rb +196 -0
  257. data/test/integration/table/query_tables_test.rb +43 -0
  258. data/test/integration/table/query_test.rb +251 -0
  259. data/test/integration/table/table_acl_test.rb +52 -0
  260. data/test/integration/table/table_gb18030_test.rb +355 -0
  261. data/test/integration/table/update_entity_batch_test.rb +149 -0
  262. data/test/integration/table/update_entity_test.rb +131 -0
  263. data/test/integration/test_helper.rb +40 -0
  264. data/test/integration/vm/VM_Create_test.rb +262 -0
  265. data/test/integration/vm/VM_Delete_test.rb +53 -0
  266. data/test/integration/vm/VM_Operations_test.rb +172 -0
  267. data/test/integration/vm_image/virtual_machine_disk_test.rb +37 -0
  268. data/test/integration/vm_image/virtual_machine_image_test.rb +37 -0
  269. data/test/integration/vnet/Virtual_Network_Create_test.rb +116 -0
  270. data/test/integration/vnet/Virtual_Network_list_test.rb +48 -0
  271. data/test/support/env.rb +19 -0
  272. data/test/support/fixtures.rb +36 -0
  273. data/test/support/name_generator.rb +168 -0
  274. data/test/support/stubs.rb +42 -0
  275. data/test/support/virtual_machine_name_generator.rb +102 -0
  276. data/test/support/virtual_network_helper.rb +73 -0
  277. data/test/test_helper.rb +47 -0
  278. data/test/unit/affinity_group/affinity_group_test.rb +189 -0
  279. data/test/unit/affinity_group/serialization_test.rb +87 -0
  280. data/test/unit/base_management/base_management_service_test.rb +19 -0
  281. data/test/unit/base_management/location_test.rb +56 -0
  282. data/test/unit/base_management/role_size_test.rb +50 -0
  283. data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
  284. data/test/unit/blob/blob_service_test.rb +1970 -0
  285. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +94 -0
  286. data/test/unit/cloud_service_management/serialization_test.rb +169 -0
  287. data/test/unit/config/azure_test.rb +112 -0
  288. data/test/unit/config/client_test.rb +37 -0
  289. data/test/unit/core/auth/shared_key_lite_test.rb +51 -0
  290. data/test/unit/core/auth/shared_key_test.rb +58 -0
  291. data/test/unit/core/auth/signer_test.rb +30 -0
  292. data/test/unit/core/http/http_error_test.rb +61 -0
  293. data/test/unit/core/http/http_request_test.rb +138 -0
  294. data/test/unit/core/http/http_response_test.rb +20 -0
  295. data/test/unit/core/http/retry_policy_test.rb +23 -0
  296. data/test/unit/core/utility_test.rb +122 -0
  297. data/test/unit/database/serialization_test.rb +94 -0
  298. data/test/unit/database/sql_database_server_service_test.rb +341 -0
  299. data/test/unit/http_client_test.rb +74 -0
  300. data/test/unit/service/serialization_test.rb +533 -0
  301. data/test/unit/service/storage_service_test.rb +297 -0
  302. data/test/unit/storage_management/serialization_test.rb +244 -0
  303. data/test/unit/storage_management/storage_management_service_test.rb +247 -0
  304. data/test/unit/table/edmtype_test.rb +108 -0
  305. data/test/unit/virtual_machine_image_management/serialization_test.rb +50 -0
  306. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +114 -0
  307. data/test/unit/virtual_machine_management/serialization_test.rb +316 -0
  308. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +480 -0
  309. data/test/unit/vnet/serialization_test.rb +187 -0
  310. data/test/unit/vnet/virtual_network_management_service_test.rb +131 -0
  311. metadata +579 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8e53ed9868e24340da35c2918563b62ea290d3a
4
+ data.tar.gz: cd3cfea5d0e0692d8921489c4abed4f3dad63bf8
5
+ SHA512:
6
+ metadata.gz: fd0a8116ea8b652bd0b56dbae6e8c9a3821181537adc2d1d7ffd99eed4f7bb556d9d99f15c3552b0ff080f5a1cd7ddb2d17ce994ec1145800d9cd18dfcbfddac
7
+ data.tar.gz: eefd8140b3ca90e617021503e9ee60714c4e0cf36dd7fa16a4d60a85280fa243c8621feefd4481c72d32f6de213af54488f3a08e903d5bc8f455f6f2bd547fed
@@ -0,0 +1,13 @@
1
+ # This is a sample of what your .env file should look like if you wanted to run integration tests.
2
+ # If you move this file to the .env and replace the environment variables with your own values, then the environment
3
+ # will be included when the rake test tasks are executed. Otherwise, you could just export the environment vars
4
+ # yourself.
5
+
6
+ AZURE_STORAGE_ACCOUNT="your storage account"
7
+ AZURE_STORAGE_ACCESS_KEY="your storage access key"
8
+ AZURE_SERVICEBUS_NAMESPACE="your sb namespace"
9
+ AZURE_SERVICEBUS_ACCESS_KEY="your sb access key"
10
+ AZURE_MANAGEMENT_CERTIFICATE="your management cert path"
11
+ AZURE_SUBSCRIPTION_ID="your subscription id"
12
+ AZURE_SERVICEBUS_SAS_KEY="Service Bus SAS key"
13
+ AZURE_SERVICEBUS_SAS_KEY_NAME="Service Bus SAS key name"
@@ -0,0 +1,30 @@
1
+ .rvmrc
2
+ *.gem
3
+ *.rbc
4
+ *.swp
5
+ *.tmproj
6
+ *~
7
+ .\#*
8
+ tags
9
+ /pkg
10
+ /doc
11
+ Gemfile.lock
12
+ nbproject/*
13
+ *.gem
14
+ .idea/*
15
+ .project
16
+ .bundle
17
+ .config
18
+ .yardoc
19
+ _yardoc
20
+ coverage
21
+ doc/
22
+ lib/bundler/man
23
+ pkg
24
+ rdoc
25
+
26
+
27
+ .DS_Store
28
+ .ruby-version
29
+ .env
30
+ *.pem
@@ -0,0 +1,13 @@
1
+ ---
2
+ language: ruby
3
+
4
+ rvm:
5
+ - 1.9.3
6
+ - 2.0.0
7
+ - 2.1.5
8
+ - 2.2.0
9
+
10
+ script:
11
+ - bundle exec rake test:unit
12
+ - if [ "$TRAVIS_SECURE_ENV_VARS" == "true" ] ; then rake test:integration ; fi
13
+
@@ -0,0 +1,56 @@
1
+ 2015.05.06 - version 0.7.0.pre
2
+ * Upgraded ASM versioning to 2014-06-01
3
+ * Added the ability to use personal vm images not just gallery images
4
+ * Namespaced all of the things so there is no leakage
5
+ * Added proper support for .pfx
6
+ * Added bin to transform .publishsettings files to .pfx files
7
+ * Added support for Azure.config.management_certificate as string
8
+ * Added ms-blob-content-disposition support, bump blob `x-ms-version` header to `2013-08-15`
9
+ * Fixed KeepAlive and timeout for blobs
10
+ * VM sizes are available -- we just warn if they are not in our list
11
+ * Support for nokogiri on windows
12
+ * Ability to delete a staging deployment of a cloud service
13
+ * Peek_lock fixed for service bus
14
+ * Support for creating shared access signatures
15
+
16
+
17
+ 2014.05.06 - version 0.6.4
18
+ * Upgraded Service Management Versioning to 2014-04-01
19
+ * Created separate API for add role
20
+ * Logical Unit Number(lun) is optional argument in API add_data_disk
21
+ * Cloud service should delete only if there are no other VMs/Deployments in the cloud service
22
+ * Added more sizes(Basic_A0, Basic_A1, Basic_A2, Basic_A3, Basic_A4) options for Virtual Machine and Cloud Service.
23
+
24
+ 2014.03.28 - version 0.6.3
25
+ * Added get_cloud_service_properties method, which returns all cloud service properties (embed-detail=true), including info about all VMs
26
+ * Added winrm_http_port and winrm_https_port to get_virtual_machine method to allow the users to configure custom ports for winrm-http and winrm-https
27
+ * Checks if any ports are in use before adding a role in the existing cloud service
28
+ * Auto generate public port for add role.
29
+ * Fix issue https://github.com/Azure/azure-sdk-for-ruby/issues/130
30
+
31
+ 2014.03.15 - version 0.6.2
32
+ * Restart Virtual Machine
33
+ * Add disk to Virtual Machine
34
+ * Add/Update Virtual Machine endpoints
35
+ * Delete Virtual Machine endpoint
36
+
37
+ 2014.02.18 - version 0.6.1
38
+ * Fixed http redirection error
39
+ * Add a new role to existing deployment
40
+ * Add support for including VMs in availability sets
41
+
42
+ 2013.12.02 - version 0.6.0
43
+ * Add the following service management API
44
+ * Virtual Machine
45
+ * Virtual Machine Image
46
+ * Virtual Network
47
+ * Cloud Service
48
+ * Storage
49
+ * Sql Database
50
+ * Location and Affinity Group
51
+
52
+ 2013.04.25 - version 0.5.0
53
+ * First release
54
+ * Ruby 1.9.3 and 2.0 support
55
+ * Storage support: Blob, Table and Queue
56
+ * Service Bus support: Queue, Topic/Subscription
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ #-------------------------------------------------------------------------
2
+ # # Copyright (c) Microsoft and contributors. All rights reserved.
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #--------------------------------------------------------------------------
15
+ source 'https://rubygems.org'
16
+ gemspec
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2015 Microsoft Corporation
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,702 @@
1
+
2
+ # Microsoft Azure SDK for Ruby
3
+ [![Build Status](https://travis-ci.org/Azure/azure-sdk-for-ruby.png?branch=dev)](https://travis-ci.org/Azure/azure-sdk-for-ruby) [![Code Climate](https://codeclimate.com/github/Azure/azure-sdk-for-ruby/badges/gpa.svg)](https://codeclimate.com/github/Azure/azure-sdk-for-ruby)
4
+
5
+
6
+ This project provides a Ruby package that makes it easy to access and manage Microsoft Azure Services like Storage, Service Bus and Virtual Machines.
7
+
8
+ # Library Features
9
+
10
+ * [Storage](#storage)
11
+ * [Blobs](#blobs)
12
+ * [Tables](#tables)
13
+ * [Queues](#queues)
14
+ * Storage Account Management
15
+ * [Service Bus](#service-bus)
16
+ * [relays](#relays)
17
+ * [Queues](#sb-queues)
18
+ * [Topics](#topics)
19
+ * [Base Management](#base-mgmt)
20
+ * [Locations](#locations)
21
+ * [Affinity Groups](#affinity)
22
+ * [Virtual Machine Management](#vms)
23
+ * list, delete Disks
24
+ * manage virtual machines
25
+ * [list images](#images)
26
+ * Cloud Service Management
27
+ * [SQL Database Server Management](#sql)
28
+ * [Virtual Network Management](#vnets)
29
+ * List VNet
30
+ * Create VNet via parameters or xml file
31
+
32
+ # Supported Ruby Versions
33
+
34
+ * Ruby 1.9.3
35
+ * Ruby 2.0
36
+ * Ruby 2.1
37
+ * Ruby 2.2
38
+
39
+ Note: x64 Ruby for Windows is known to have some compatibility issues.
40
+
41
+ # Getting Started
42
+
43
+ ## Install the rubygem package
44
+
45
+ You can install the azure rubygem package directly.
46
+
47
+ ```bash
48
+ gem install azure
49
+ ```
50
+
51
+ ## Setup Connection
52
+
53
+ You can use this SDK against the Microsoft Azure Services in the cloud, or against the local Storage Emulator if you are on Windows. Service Bus and Microsoft Azure Service Management emulation are not supported. Of course, to use the Microsoft Azure Services in the cloud, you need to first [create a Microsoft Azure account](http://www.azure.com/en-us/pricing/free-trial/). After that, you can get the information you need to configure Storage and Service Bus from the [Microsoft Azure Portal](https://manage.azure.com).
54
+
55
+ There are two ways you can set up the connections:
56
+
57
+ 1. [via code](#via-code)
58
+ 2. [via environment variables](#via-environment-variables)
59
+
60
+ <a name="via-code"></a>
61
+ ### Via Code
62
+ * Against Microsoft Azure Services in the cloud
63
+
64
+ ```ruby
65
+
66
+ require "azure"
67
+
68
+ Azure.storage_account_name = "<your azure storage account name>"
69
+ Azure.storage_access_key = "<your azure storage access key>"
70
+
71
+ # Configure these 3 properties to use Service Bus
72
+ Azure.sb_namespace = "<your azure service bus namespace>"
73
+ Azure.sb_access_key = "<your azure service bus access key>"
74
+ Azure.sb_issuer = "<your azure service bus issuer>"
75
+
76
+ # Configure these 3 properties to use Service Management. We support passwordless pfx & pem cert formats.
77
+ Azure.management_certificate = "<path to your *.pem or *.pfx>"
78
+ Azure.subscription_id = "<your Subscriptionid>"
79
+
80
+ # Configure a ca_cert.pem file if you are having issues with ssl peer verification
81
+ Azure.ca_file = "./ca_file.pem"
82
+
83
+ # Or create a specific instance of an Azure.client, which will inherit your default configuration settings.
84
+ client = Azure.client(storage_account_name: "your account name", storage_access_key: "your access key")
85
+
86
+ ```
87
+
88
+ * Against local Emulator (Windows Only)
89
+
90
+ ```ruby
91
+
92
+ require "azure"
93
+
94
+ # Configure these 2 properties to use local Storage Emulator
95
+ Azure.storage_account_name = "devstoreaccount1"
96
+ Azure.storage_access_key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
97
+
98
+ Azure.storage_blob_host = "http://127.0.0.1:10000/devstoreaccount1"
99
+ Azure.storage_queue_host = "http://127.0.0.1:10001/devstoreaccount1"
100
+ Azure.storage_table_host = "http://127.0.0.1:10002/devstoreaccount1"
101
+
102
+ # Local Service Bus Emulator is not supported
103
+ # Local Service Management emulation is not supported
104
+
105
+ ```
106
+
107
+ <a name="via-environment-variables"></a>
108
+ ### Via Environment Variables
109
+
110
+ * Against Microsoft Azure Services in the cloud
111
+
112
+ * Storage
113
+
114
+ ```bash
115
+ AZURE_STORAGE_ACCOUNT = <your azure storage account name>
116
+ AZURE_STORAGE_ACCESS_KEY = <your azure storage access key>
117
+ ```
118
+ * Service Bus
119
+
120
+ ```bash
121
+ AZURE_SERVICEBUS_NAMESPACE = <your azure service bus namespace>
122
+ AZURE_SERVICEBUS_ACCESS_KEY = <your azure service bus access key>
123
+ AZURE_SERVICEBUS_ISSUER = <your azure service bus issuer>
124
+ ```
125
+ * Service Management
126
+
127
+ ```bash
128
+ AZURE_MANAGEMENT_CERTIFICATE = <path to *.pem or *.pfx>
129
+ AZURE_SUBSCRIPTION_ID = <your subscription ID>
130
+ AZURE_MANAGEMENT_ENDPOINT = <The endpoint URL of Microsoft Azure management service>
131
+ AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT = <SQL Database Management Endpoint>
132
+ AZURE_SQL_DATABASE_AUTHENTICATION_MODE = <:management_certificate or :sql_server>
133
+ ```
134
+ * [SSL Certificate File](https://gist.github.com/fnichol/867550)
135
+
136
+ ```bash
137
+ SSL_CERT_FILE=<path to *.pem>
138
+ ```
139
+ * Against local Emulator (Windows Only)
140
+
141
+ * Storage
142
+
143
+ ```bash
144
+ AZURE_STORAGE_ACCOUNT = devstoreaccount1
145
+ AZURE_STORAGE_ACCESS_KEY = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
146
+ AZURE_STORAGE_BLOB_HOST = http://127.0.0.1:10000/devstoreaccount1
147
+ AZURE_STORAGE_QUEUE_HOST = http://127.0.0.1:10001/devstoreaccount1
148
+ AZURE_STORAGE_TABLE_HOST = http://127.0.0.1:10002/devstoreaccount1
149
+ ```
150
+ * Service Bus: not supported
151
+
152
+ * Service Management: not supported
153
+
154
+ # Usage
155
+
156
+ <a name="storage"></a>
157
+ ## Storage
158
+
159
+ ### Setup your Storage Credentials
160
+
161
+ ```ruby
162
+
163
+ # Require the azure rubygem
164
+ require "azure"
165
+
166
+ # Add your default storage credentials
167
+ Azure.storage_account_name = "your account name"
168
+ Azure.storage_access_key = "your access key"
169
+
170
+ # Or create a specific instance of an Azure.client
171
+ client = Azure.client(storage_account_name: "your account name", storage_access_key: "your access key")
172
+
173
+ default_blobs = Azure.blobs # uses the Azure.storage_account_name and Azure.storage_access_key
174
+
175
+ blobs = client.blobs # uses the client.storage_account_name and client.storage_access_key
176
+
177
+ ```
178
+ <a name="blobs"></a>
179
+ ### Blobs
180
+
181
+ ```ruby
182
+
183
+ # Create an azure storage blob service object
184
+ blobs = Azure.blobs
185
+
186
+ # Create a container
187
+ container = blobs.create_container("test-container")
188
+
189
+ # Upload a Blob
190
+ content = File.open('test.jpg', 'rb') { |file| file.read }
191
+ blobs.create_block_blob(container.name, "image-blob", content)
192
+
193
+ # List containers
194
+ blobs.list_containers()
195
+
196
+ # List Blobs
197
+ blobs.list_blobs(container.name)
198
+
199
+ # Download a Blob
200
+ blob, content = blobs.get_blob(container.name, "image-blob")
201
+ File.open("download.png", "wb") {|f| f.write(content)}
202
+
203
+ # Delete a Blob
204
+ blobs.delete_blob(container.name, "image-blob")
205
+
206
+ ```
207
+ <a name="tables"></a>
208
+ ### Tables
209
+
210
+ ```ruby
211
+
212
+ # Require the azure rubygem
213
+ require "azure"
214
+
215
+ # Create an azure storage table service object
216
+ tables = Azure.tables
217
+
218
+ # Create a table
219
+ tables.create_table("testtable")
220
+
221
+ # Insert an entity
222
+ entity = { "content" => "test entity", :partition_key => "test-partition-key", :row_key => "1" }
223
+ tables.insert_entity("testtable", entity)
224
+
225
+ # Get an entity
226
+ result = tables.get_entity("testtable", "test-partition-key", "1")
227
+
228
+ # Update an entity
229
+ result.properties["content"] = "test entity with updated content"
230
+ tables.update_entity(result.table, result.properties)
231
+
232
+ # Query entities
233
+ query = { :filter => "content eq 'test entity'" }
234
+ result, token = tables.query_entities("testtable", query)
235
+
236
+ # Delete an entity
237
+ tables.delete_entity("testtable", "test-partition-key", "1")
238
+
239
+ # delete a table
240
+ tables.delete_table("testtable")
241
+
242
+ ```
243
+
244
+ <a name="queues"></a>
245
+ ### Queues
246
+
247
+ ```ruby
248
+
249
+ # Require the azure rubygem
250
+ require "azure"
251
+
252
+ # Create an azure storage queue service object
253
+ queues = Azure.queues
254
+
255
+ # Create a queue
256
+ queues.create_queue("test-queue")
257
+
258
+ # Create a message
259
+ queues.create_message("test-queue", "test message")
260
+
261
+ # Get one or more messages with setting the visibility timeout
262
+ result = queues.list_messages("test-queue", 30, {:number_of_messages => 10})
263
+
264
+ # Get one or more messages without setting the visibility timeout
265
+ result = queues.peek_messages("test-queue", {:number_of_messages => 10})
266
+
267
+ # Update a message
268
+ message = queues.list_messages("test-queue", 30)
269
+ pop_receipt, time_next_visible = queues.update_message("test-queue", message.id, message.pop_receipt, "updated test message", 30)
270
+
271
+ # Delete a message
272
+ message = queues.list_messages("test-queue", 30)
273
+ queues.delete_message("test-queue", message.id, message.pop_receipt)
274
+
275
+ # Delete a queue
276
+ queues.delete_queue("test-queue")
277
+
278
+ ```
279
+
280
+ <a name="service-bus"></a>
281
+ ## Service Bus
282
+
283
+ <a name="relays"></a>
284
+ ### Relay
285
+
286
+ ```ruby
287
+
288
+ # Require the azure rubygem
289
+ require "azure"
290
+
291
+ # Create an azure service bus object
292
+ service_bus = Azure.service_bus
293
+
294
+ # Create a relay endpoint with just the endpoint name
295
+ relay1 = service_bus.create_relay("test-relay-1", { :relay_type => "Http" })
296
+
297
+ # Create a relay endpoint with a relay object
298
+ relay2 = Azure::ServiceBus::Relay.new("test-relay-2")
299
+ relay2.requires_client_authorization = false
300
+ relay2 = service_bus.create_relay(relay2)
301
+
302
+ # Delete a relay endpoint
303
+ service_bus.delete_relay("test-relay2")
304
+
305
+ ```
306
+
307
+ <a name="sb-queues"></a>
308
+ ### Queues
309
+
310
+ ```ruby
311
+
312
+ # Require the azure rubygem
313
+ require "azure"
314
+
315
+ # Create an azure service bus object
316
+ service_bus = Azure.service_bus
317
+
318
+ # Create a queue with just the queue name
319
+ queue1 = service_bus.create_queue("test-queue-1")
320
+
321
+ # Create a queue with a queue object
322
+ queue2 = Azure::ServiceBus::Queue.new("test-queue-2")
323
+ queue2.max_size_in_megabytes = 2048
324
+ queue2 = service_bus.create_queue(queue2)
325
+
326
+ # Send a queue message with just the message body
327
+ service_bus.send_queue_message("test-queue-1", "test queue message")
328
+
329
+ # Send a queue message with a brokered message object
330
+ message = Azure::ServiceBus::BrokeredMessage.new("another test queue message")
331
+ message.correlation_id = "test-correlation-id-1"
332
+ service_bus.send_queue_message("test-queue-1", message)
333
+
334
+ # Receive a queue message
335
+ message = service_bus.receive_queue_message("test-queue-1")
336
+
337
+ # Delete a queue message
338
+ service_bus.delete_queue_message(message)
339
+
340
+ # Delete a queue
341
+ service_bus.delete_queue("test-queue-1")
342
+
343
+ ```
344
+
345
+ <a name="topics"></a>
346
+ ### Topics
347
+
348
+ ```ruby
349
+
350
+ # Require the azure rubygem
351
+ require "azure"
352
+
353
+ # Create an azure service bus object
354
+ service_bus = Azure.service_bus
355
+
356
+ # Create a topic with just the topic name
357
+ topic1 = service_bus.create_topic("test-topic-1")
358
+
359
+ # Create a topic with a topic object
360
+ topic2 = Azure::ServiceBus::Topic.new("test-topic-2")
361
+ topic2.max_size_in_megabytes = 2048
362
+ topic2 = service_bus.create_topic(topic2)
363
+
364
+ # Create a subscription
365
+ subscription = Azure::ServiceBus::Subscription.new("test-subscription-1")
366
+ subscription.topic = topic1.name
367
+ subscription = service_bus.create_subscription(subscription)
368
+
369
+ # Send a topic message with just the message body
370
+ azure_service_bus.send_topic_message(topic1, "test topic message")
371
+
372
+ # Send a topic message with a brokered message object
373
+ message = Azure::ServiceBus::BrokeredMessage.new("another test topic message")
374
+ message.correlation_id = "test-correlation-id-1"
375
+ service_bus.send_topic_message(topic1, message)
376
+
377
+ # Receive a subscription message
378
+ message = service_bus.receive_subscription_message(topic1.name, subscription.name)
379
+
380
+ # Delete a subscription message
381
+ service_bus.delete_subscription_message(message)
382
+
383
+ # Delete a subscription
384
+ service_bus.delete_subscription(subscription)
385
+
386
+ # Delete a topic
387
+ service_bus.delete_topic(topic1)
388
+
389
+ ```
390
+
391
+ <a name="vms"></a>
392
+ ## Virtual Machine Management
393
+
394
+ ```ruby
395
+
396
+ # Require the azure rubygem
397
+ require 'azure'
398
+
399
+ # Configure these properties
400
+ Azure.management_certificate = "path to *.pem or *.pfx file"
401
+ Azure.subscription_id = "your subscription id"
402
+
403
+ # Create a virtual machine service object
404
+ vm_management = Azure.vm_management
405
+
406
+ # Get a list of existing virtual machines in your subscription
407
+ vm_management.list_virtual_machines
408
+
409
+ # API to shutdown Virtual Machine
410
+ vm_management.shutdown_virtual_machine('vm_name', 'cloud_service_name')
411
+
412
+ # API to start Virtual Machine
413
+ vm_management.start_virtual_machine('vm_name', 'cloud_service_name')
414
+
415
+ # API to restart Virtual Machine
416
+ vm_management.restart_virtual_machine('vm_name', 'cloud_service_name')
417
+
418
+ # API for add disk to Virtual Machine
419
+ options = {
420
+ :disk_label => 'disk-label',
421
+ :disk_size => 100, #In GB
422
+ :import => false,
423
+ :disk_name => 'Disk name' #Required when import is true
424
+ }
425
+ vm_management.add_data_disk('vm_name', 'cloud_service_name', options)
426
+
427
+ # API to add/update Virtual Machine endpoints
428
+ endpoint1 = {
429
+ :name => 'ep-1',
430
+ :public_port => 996,
431
+ :local_port => 998,
432
+ :protocol => 'TCP',
433
+ }
434
+ endpoint2 = {
435
+ :name => 'ep-2',
436
+ :public_port => 997,
437
+ :local_port => 997,
438
+ :protocol => 'TCP',
439
+ :load_balancer_name => ‘lb-ep2’,
440
+ :load_balancer => {:protocol => 'http', :path => 'hello'}
441
+ }
442
+ vm_management.update_endpoints('vm_name', 'cloud_service_name', endpoint1, endpoint2)
443
+
444
+ # API to delete Virtual Machine endpoint
445
+ vm_management.delete_endpoint('vm_name', 'cloud_service_name', 'endpoint_name')
446
+
447
+ # API to delete Virtual Machine
448
+ vm_management.delete_virtual_machine('vm_name', 'cloud_service_name')
449
+
450
+ # API to start deployment
451
+ params = {
452
+ :vm_name => 'vm_name',
453
+ :vm_user => 'azureuser',
454
+ :image => '5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-63APR20130415',
455
+ :password => 'Password',
456
+ :location => 'West US'
457
+ }
458
+ options = {
459
+ :storage_account_name => 'storage_suse',
460
+ :cloud_service_name => 'cloud_service_name',
461
+ :deployment_name =>'vm_name',
462
+ :tcp_endpoints => '80,3389:3390',
463
+ :private_key_file => './private_key.key', # required for ssh
464
+ :ssh_port => 2222,
465
+ :vm_size => 'Small', # Use any Azure VM size
466
+ :affinity_group_name => 'affinity1',
467
+ :virtual_network_name => 'xplattestvnet',
468
+ :subnet_name => 'subnet1',
469
+ :availability_set_name => 'availabiltyset1',
470
+ :reserved_ip_name => 'reservedipname'
471
+ }
472
+ vm_management.create_virtual_machine(params,options)
473
+
474
+ # API usage to add new roles under cloud service creating VM
475
+ # API add_role create multiple roles under the same cloud service. Atleast a single deployment should be created under a hosted service.
476
+ params = {
477
+ :vm_name => 'vm_name',
478
+ :cloud_service_name => 'cloud_service_name',
479
+ :vm_user => 'azureuser',
480
+ :image => 'a699494373c04fc0bc8f2bb1389d6106__Win2K8R2SP1-Datacenter-201305.01-en.us-127GB.vhd',
481
+ :password => 'ComplexPassword',
482
+ }
483
+ options = {
484
+ :storage_account_name => 'storage_suse',
485
+ :winrm_transport => ['https','http'], # Currently http(s) is supported.
486
+ :tcp_endpoints => '80,3389:3390',
487
+ :private_key_file => './private_key.key', # Required for winrm(https) certificate.
488
+ :winrm_https_port => 5999,
489
+ :winrm_http_port => 6999, # Used to open different powershell port
490
+ :vm_size => 'Small', # Use any Azure VM size
491
+ :availability_set_name => 'availabiltyset'
492
+ }
493
+ vm_management.add_role(params, options)
494
+
495
+ ```
496
+
497
+ <a name="images"></a>
498
+ ## List Images
499
+
500
+ ```ruby
501
+
502
+ # Get a list of available virtual machine images
503
+ vm_image_management = Azure.vm_image_management
504
+ vm_image_management.list_virtual_machine_images
505
+
506
+ ```
507
+
508
+ <a name="base-mgmt"></a>
509
+ ## Base Management
510
+
511
+ <a name="locations"></a>
512
+ ```ruby
513
+
514
+ # Get a list of available regional data center locations
515
+ base_management = Azure.base_management
516
+ base_management.list_locations
517
+
518
+ ```
519
+
520
+ <a name="affinity"></a>
521
+ ### Affinity Group Management
522
+
523
+ ```ruby
524
+
525
+ # Require the azure rubygem
526
+ require 'azure'
527
+
528
+ # Create a affinity group service object
529
+ base_management = Azure.base_management
530
+
531
+ # Get a list of affinity group that are provisioned for a subscription.
532
+ base_management.list_affinity_groups
533
+
534
+ # API to delete affinity group
535
+ base_management.delete_affinity_group('affinity-group-name')
536
+
537
+ # API to add a new affinity group to a subscription
538
+ options = {:description => 'Some Description'}
539
+ base_management.create_affinity_group('affinity-group-name', 'West US', 'Label Name', options)
540
+
541
+ # API to update affinity group
542
+ options = {:description => 'Some Description'}
543
+ base_management.update_affinity_group('affinity-group-name', 'Label Name', options)
544
+
545
+ # API to list properties associated with the specified affinity group
546
+ base_management.get_affinity_group('affinity-group-name')
547
+
548
+ ```
549
+
550
+ <a name="sql"></a>
551
+ ## SQL Database Server Management
552
+
553
+ ```ruby
554
+
555
+ # Require the azure rubygem
556
+ require 'azure'
557
+
558
+ # Configure these properties
559
+ Azure.management_certificate = "path to *.pem or *.pfx file"
560
+ Azure.subscription_id = "your subscription id"
561
+
562
+ # Create a database server service object
563
+ sql_db_service = Azure.sql_database_management
564
+
565
+ # Get a list of SQL Database servers that are provisioned for a subscription.
566
+ sql_db_service.list_servers
567
+
568
+ # API to delete SQL Database server
569
+ sql_db_service.delete_server('server_name')
570
+
571
+ # API to adds a new SQL Database server to a subscription
572
+ sql_db_service.create_server('admin-login', 'ComplexPassword', 'West US')
573
+
574
+ # API to sets the administrative password of a SQL Database server for a subscription
575
+ sql_db_service.reset_password('server-name', 'NewPassword')
576
+
577
+ # Get a list of all the server-level firewall rules for a SQL Database server that belongs to a subscription
578
+ sql_db_service.list_sql_server_firewall_rules("server-name")
579
+
580
+ # API to adds a new server-level firewall rule or updates an existing server-level firewall rule for a SQL Database server with requester’s IP address.
581
+ sql_db_service.delete_sql_server_firewall_rule("server-name", "rule-name")
582
+
583
+ # API to add/updates server-level firewall rule for a SQL Database server that belongs to a subscription
584
+ ip_range = {:start_ip_address => "0.0.0.1", :end_ip_address => "0.0.0.5"}
585
+ sql_db_service.set_sql_server_firewall_rule("server-name", "rule-name", ip_range)
586
+
587
+ # If ip_range was not specified in the above api then the IP of the machine from where the api is being called would be set as the rule.
588
+ # To toggle between the option to allow Microsoft Azure services to access db server similar to azure portal just set the fire wall rule
589
+ # with iprange to be 0.0.0.0 as start and end.Remove the rule to unset this option.
590
+
591
+ ```
592
+
593
+ <a name="vnets"></a>
594
+ ## Virtual Network Management
595
+
596
+ ```ruby
597
+
598
+ # Require the azure rubygem
599
+ require 'azure'
600
+
601
+ # Create a virtual network service object
602
+ vnet = Azure.network_management
603
+
604
+ # API to get a list of virtual networks created for a subscription.
605
+ vnet.list_virtual_networks
606
+
607
+ # API to configure virtual network with required and optional parameters
608
+ address_space = ['172.16.0.0/12', '10.0.0.0/8', '192.168.0.0/24']
609
+ subnets = [{:name => 'subnet-1', :ip_address=>'172.16.0.0', :cidr=>12}, {:name => 'subnet-2', :ip_address=>'10.0.0.0', :cidr=>8}]
610
+ dns_servers = [{:name => 'dns-1', :ip_address=>'1.2.3.4'}, {:name => 'dns-2', :ip_address=>'8.7.6.5'}]
611
+ options = {:subnet => subnets, :dns => dns_servers}
612
+ vnet.set_network_configuration('virtual-network-name', 'location_name', address_space, options)
613
+
614
+ # API to configure virtual network from xml file that can be exported from management portal and customized to add or delete vnet
615
+ vnetxml = './customnetwork.xml'
616
+ vnet.set_network_configuration(vnetxml)
617
+
618
+ ```
619
+
620
+ # Getting Started with Certificates
621
+
622
+ Currently the sdk supports *.pem or *.pfx (passwordless pfx) for service management operations. Following are the steps discussed on various cert operations.
623
+
624
+ ## Get Started with Publish Settings
625
+
626
+ * To create a pfx from the publishsettings, simply download the publishsettings file for your subscription
627
+ [https://manage.windowsazure.com/publishsettings](https://manage.windowsazure.com/publishsettings/index?client=powershell). Make sure you have this gem installed and
628
+ run `pfxer --in [path to your .publishsettings file]`. This will create a .pfx from your publish settings file which can
629
+ be supplied as a cert parameter for Service Management Commands.
630
+
631
+ ## Get Started with OpenSSL
632
+
633
+ * Using the following openssl commands to create a cert and upload to Azure Management
634
+ * Generate public and private `openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout cert.pem -out cert.pem`
635
+ * Generate public .cer for Azure upload `openssl x509 -inform pem -in cert.pem -outform der -out mgmt.cer`
636
+ * Upload the `mgmt.cer` to Azure Management through [https://management.azure.com](https://management.azure.com)
637
+ * Use cert.pem as your cert parameter for Service Management Commands.
638
+
639
+ # Contribute Code or Provide Feedback
640
+
641
+ 1. Fork it
642
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
643
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
644
+ 4. Push to the branch (`git push origin my-new-feature`)
645
+ 5. Create new Pull Request
646
+
647
+
648
+ ## Development Environment Setup
649
+
650
+ ### Download Source Code
651
+
652
+ To get the source code of the SDK via **git** just type:
653
+
654
+ ```bash
655
+ git clone https://github.com/Azure/azure-sdk-for-ruby.git
656
+ cd ./azure-sdk-for-ruby
657
+ ```
658
+
659
+ Then, run bundler to install all the gem dependencies:
660
+
661
+ ```bash
662
+ bundle install
663
+ ```
664
+
665
+ ### Setup the Environment for Integration Tests
666
+
667
+ If you would like to run the integration test suite, you will need to setup environment variables which will be used
668
+ during the integration tests. These tests will use these credentials to run live tests against Azure with the provided
669
+ credentials (you will be charged for usage, so verify the clean up scripts did their job at the end of a test run).
670
+
671
+ The root of the project contains a .env_sample file. This dot file is a sample of the actual environment vars needed to
672
+ run the integration tests.
673
+
674
+ Do the following to prepare your environment for integration tests:
675
+
676
+ * Copy .env_sample to .env **relative to root of the project dir**
677
+ * Update .env with your credentials **.env is in the .gitignore, so should only reside locally**
678
+
679
+ ### Run Tests
680
+
681
+ You can use the following commands to run:
682
+
683
+ * All the tests: ``rake test``. **This will run integration tests if you have .env file or env vars setup**
684
+ * A specific suite of tests: ``rake test:unit``, ``rake test:integration``, ``rake test:integration:blob``, etc.
685
+ * one particular test file: ``ruby -I"lib:test" "<path of the test file>"``
686
+
687
+ ### Generate Documentation
688
+
689
+ Running the command ``yard`` will generate the API documentation in the `./doc` directory.
690
+
691
+ ## Provide Feedback
692
+
693
+ If you encounter any bugs with the library please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-ruby/issues) section of the project.
694
+
695
+ # Maintainers
696
+
697
+ * [David Justice](https://github.com/devigned)
698
+
699
+ # Azure CLI Tooling
700
+
701
+ For documentation on [Azure PowerShell](http://github.com/azure/azure-powershell).
702
+ For documentation on [Azure CLI](http://github.com/azure/azure-xplat-cli).