juliusl-azure-sdk-for-ruby 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (300) hide show
  1. checksums.yaml +7 -0
  2. data/.env_sample +11 -0
  3. data/.gitignore +15 -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 +630 -0
  9. data/Rakefile +121 -0
  10. data/azure.gemspec +47 -0
  11. data/bin/pfxer +35 -0
  12. data/lib/azure.rb +60 -0
  13. data/lib/azure/base_management/affinity_group.rb +32 -0
  14. data/lib/azure/base_management/base_management_service.rb +245 -0
  15. data/lib/azure/base_management/location.rb +27 -0
  16. data/lib/azure/base_management/management_http_request.rb +175 -0
  17. data/lib/azure/base_management/serialization.rb +135 -0
  18. data/lib/azure/base_management/sql_management_http_request.rb +45 -0
  19. data/lib/azure/blob/auth/shared_access_signature.rb +141 -0
  20. data/lib/azure/blob/blob.rb +32 -0
  21. data/lib/azure/blob/blob_service.rb +1427 -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/cloud_service_management/cloud_service.rb +38 -0
  26. data/lib/azure/cloud_service_management/cloud_service_management_service.rb +137 -0
  27. data/lib/azure/cloud_service_management/serialization.rb +118 -0
  28. data/lib/azure/core.rb +41 -0
  29. data/lib/azure/core/auth/authorizer.rb +36 -0
  30. data/lib/azure/core/auth/shared_key.rb +110 -0
  31. data/lib/azure/core/auth/shared_key_lite.rb +48 -0
  32. data/lib/azure/core/auth/signer.rb +52 -0
  33. data/lib/azure/core/configuration.rb +218 -0
  34. data/lib/azure/core/error.rb +22 -0
  35. data/lib/azure/core/filtered_service.rb +44 -0
  36. data/lib/azure/core/http/debug_filter.rb +36 -0
  37. data/lib/azure/core/http/http_error.rb +88 -0
  38. data/lib/azure/core/http/http_filter.rb +53 -0
  39. data/lib/azure/core/http/http_request.rb +160 -0
  40. data/lib/azure/core/http/http_response.rb +140 -0
  41. data/lib/azure/core/http/retry_policy.rb +74 -0
  42. data/lib/azure/core/http/signer_filter.rb +34 -0
  43. data/lib/azure/core/service.rb +63 -0
  44. data/lib/azure/core/signed_service.rb +43 -0
  45. data/lib/azure/core/utility.rb +242 -0
  46. data/lib/azure/queue/message.rb +30 -0
  47. data/lib/azure/queue/queue.rb +29 -0
  48. data/lib/azure/queue/queue_service.rb +568 -0
  49. data/lib/azure/queue/serialization.rb +106 -0
  50. data/lib/azure/service/access_policy.rb +26 -0
  51. data/lib/azure/service/cors.rb +11 -0
  52. data/lib/azure/service/cors_rule.rb +15 -0
  53. data/lib/azure/service/enumeration_results.rb +21 -0
  54. data/lib/azure/service/logging.rb +32 -0
  55. data/lib/azure/service/metrics.rb +31 -0
  56. data/lib/azure/service/retention_policy.rb +25 -0
  57. data/lib/azure/service/serialization.rb +299 -0
  58. data/lib/azure/service/signed_identifier.rb +30 -0
  59. data/lib/azure/service/storage_service.rb +83 -0
  60. data/lib/azure/service/storage_service_properties.rb +37 -0
  61. data/lib/azure/service_bus/action.rb +21 -0
  62. data/lib/azure/service_bus/auth/wrap_service.rb +89 -0
  63. data/lib/azure/service_bus/auth/wrap_signer.rb +69 -0
  64. data/lib/azure/service_bus/brokered_message.rb +124 -0
  65. data/lib/azure/service_bus/brokered_message_serializer.rb +159 -0
  66. data/lib/azure/service_bus/correlation_filter.rb +45 -0
  67. data/lib/azure/service_bus/empty_rule_action.rb +30 -0
  68. data/lib/azure/service_bus/false_filter.rb +38 -0
  69. data/lib/azure/service_bus/filter.rb +21 -0
  70. data/lib/azure/service_bus/interval.rb +104 -0
  71. data/lib/azure/service_bus/queue.rb +230 -0
  72. data/lib/azure/service_bus/relay.rb +88 -0
  73. data/lib/azure/service_bus/resource.rb +109 -0
  74. data/lib/azure/service_bus/rule.rb +98 -0
  75. data/lib/azure/service_bus/rule_aspect.rb +34 -0
  76. data/lib/azure/service_bus/serialization.rb +161 -0
  77. data/lib/azure/service_bus/service_bus_service.rb +895 -0
  78. data/lib/azure/service_bus/sql_filter.rb +50 -0
  79. data/lib/azure/service_bus/sql_rule_action.rb +50 -0
  80. data/lib/azure/service_bus/subscription.rb +184 -0
  81. data/lib/azure/service_bus/topic.rb +187 -0
  82. data/lib/azure/service_bus/true_filter.rb +38 -0
  83. data/lib/azure/sql_database_management/serialization.rb +112 -0
  84. data/lib/azure/sql_database_management/sql_database.rb +31 -0
  85. data/lib/azure/sql_database_management/sql_database_management_service.rb +200 -0
  86. data/lib/azure/storage_management/serialization.rb +204 -0
  87. data/lib/azure/storage_management/storage_account.rb +48 -0
  88. data/lib/azure/storage_management/storage_management_service.rb +208 -0
  89. data/lib/azure/table/auth/shared_key.rb +92 -0
  90. data/lib/azure/table/auth/shared_key_lite.rb +44 -0
  91. data/lib/azure/table/batch.rb +330 -0
  92. data/lib/azure/table/batch_response.rb +118 -0
  93. data/lib/azure/table/edmtype.rb +127 -0
  94. data/lib/azure/table/entity.rb +31 -0
  95. data/lib/azure/table/guid.rb +24 -0
  96. data/lib/azure/table/query.rb +112 -0
  97. data/lib/azure/table/serialization.rb +108 -0
  98. data/lib/azure/table/table_service.rb +560 -0
  99. data/lib/azure/version.rb +31 -0
  100. data/lib/azure/virtual_machine_image_management/serialization.rb +70 -0
  101. data/lib/azure/virtual_machine_image_management/virtual_machine_disk.rb +25 -0
  102. data/lib/azure/virtual_machine_image_management/virtual_machine_image.rb +25 -0
  103. data/lib/azure/virtual_machine_image_management/virtual_machine_image_management_service.rb +89 -0
  104. data/lib/azure/virtual_machine_management/serialization.rb +459 -0
  105. data/lib/azure/virtual_machine_management/virtual_machine.rb +44 -0
  106. data/lib/azure/virtual_machine_management/virtual_machine_management_service.rb +554 -0
  107. data/lib/azure/virtual_network_management/serialization.rb +193 -0
  108. data/lib/azure/virtual_network_management/virtual_network.rb +37 -0
  109. data/lib/azure/virtual_network_management/virtual_network_management_service.rb +109 -0
  110. data/test/fixtures/32px-fulls-black.jpg +0 -0
  111. data/test/fixtures/affinity_group.xml +33 -0
  112. data/test/fixtures/all_containers.xml +20 -0
  113. data/test/fixtures/all_tables.xml +22 -0
  114. data/test/fixtures/container_acl.xml +11 -0
  115. data/test/fixtures/create_sql_database_server.xml +2 -0
  116. data/test/fixtures/create_storage_desc_error.xml +5 -0
  117. data/test/fixtures/create_storage_extendedprop_error.xml +8 -0
  118. data/test/fixtures/create_storage_extendedpropname_error.xml +6 -0
  119. data/test/fixtures/create_storage_full_error.xml +6 -0
  120. data/test/fixtures/create_storage_label_error.xml +5 -0
  121. data/test/fixtures/create_storage_location_error.xml +5 -0
  122. data/test/fixtures/create_storage_name_error.xml +6 -0
  123. data/test/fixtures/create_table_response_entry.xml +15 -0
  124. data/test/fixtures/delete_storage_container_error.xml +5 -0
  125. data/test/fixtures/delete_storage_error.xml +5 -0
  126. data/test/fixtures/deployment_error.xml +5 -0
  127. data/test/fixtures/empty_xml_file +0 -0
  128. data/test/fixtures/get_storage_account_error.xml +5 -0
  129. data/test/fixtures/get_storage_account_properties.xml +34 -0
  130. data/test/fixtures/get_storage_account_properties_new.xml +32 -0
  131. data/test/fixtures/http_error.xml +5 -0
  132. data/test/fixtures/insert_entity_response_entry.xml +25 -0
  133. data/test/fixtures/list_affinity_groups.xml +22 -0
  134. data/test/fixtures/list_blobs.xml +121 -0
  135. data/test/fixtures/list_block_all_with_none_committed.xml +22 -0
  136. data/test/fixtures/list_blocks_all.xml +23 -0
  137. data/test/fixtures/list_blocks_committed.xml +13 -0
  138. data/test/fixtures/list_cloud_services.xml +39 -0
  139. data/test/fixtures/list_containers.xml +38 -0
  140. data/test/fixtures/list_firewall_management_endpoint.xml +27 -0
  141. data/test/fixtures/list_locations.xml +212 -0
  142. data/test/fixtures/list_os_images.xml +110 -0
  143. data/test/fixtures/list_page_ranges.xml +11 -0
  144. data/test/fixtures/list_sql_database.xml +36 -0
  145. data/test/fixtures/list_sql_server_firewall.xml +23 -0
  146. data/test/fixtures/list_storage_account_single.xml +25 -0
  147. data/test/fixtures/list_storage_accounts.xml +48 -0
  148. data/test/fixtures/list_virtual_networks.xml +92 -0
  149. data/test/fixtures/list_vm_images.xml +21 -0
  150. data/test/fixtures/logging.xml +11 -0
  151. data/test/fixtures/messages.xml +12 -0
  152. data/test/fixtures/metrics.xml +10 -0
  153. data/test/fixtures/privatekey.key +28 -0
  154. data/test/fixtures/query_entities_empty_response.xml +7 -0
  155. data/test/fixtures/query_entities_response.xml +45 -0
  156. data/test/fixtures/queue_service_properties.xml +22 -0
  157. data/test/fixtures/queue_service_properties_original.xml +19 -0
  158. data/test/fixtures/queues.xml +16 -0
  159. data/test/fixtures/retention_policy.xml +5 -0
  160. data/test/fixtures/sb_default_create_queue_response.xml +23 -0
  161. data/test/fixtures/sb_default_create_relay_response.xml +15 -0
  162. data/test/fixtures/sb_default_create_topic_response.xml +18 -0
  163. data/test/fixtures/sb_get_access_token_response.txt +1 -0
  164. data/test/fixtures/sb_queues_runtime_peek_message_response_headers.txt +9 -0
  165. data/test/fixtures/storage_service_keys.xml +8 -0
  166. data/test/fixtures/storage_service_properties.xml +55 -0
  167. data/test/fixtures/update_storage_account.xml +16 -0
  168. data/test/fixtures/update_storage_error.xml +5 -0
  169. data/test/fixtures/updated_storage_accounts.xml +55 -0
  170. data/test/fixtures/virtual_machine.xml +116 -0
  171. data/test/fixtures/windows_virtual_machine.xml +106 -0
  172. data/test/integration/affinity_group/Affinity_test.rb +55 -0
  173. data/test/integration/affinity_group/Create_Affinity_test.rb +64 -0
  174. data/test/integration/affinity_group/Delete_Affinity_test.rb +56 -0
  175. data/test/integration/affinity_group/List_Affinity_test.rb +41 -0
  176. data/test/integration/affinity_group/Update_Affinity_test.rb +83 -0
  177. data/test/integration/blob/blob_gb18030_test.rb +199 -0
  178. data/test/integration/blob/blob_metadata_test.rb +75 -0
  179. data/test/integration/blob/blob_pages_test.rb +119 -0
  180. data/test/integration/blob/blob_properties_test.rb +77 -0
  181. data/test/integration/blob/block_blob_test.rb +254 -0
  182. data/test/integration/blob/container/container_acl_test.rb +69 -0
  183. data/test/integration/blob/container/container_metadata_test.rb +50 -0
  184. data/test/integration/blob/container/create_container_test.rb +60 -0
  185. data/test/integration/blob/container/delete_container_test.rb +39 -0
  186. data/test/integration/blob/container/get_container_properties_test.rb +48 -0
  187. data/test/integration/blob/container/list_containers_test.rb +79 -0
  188. data/test/integration/blob/container/root_container_test.rb +54 -0
  189. data/test/integration/blob/copy_blob_test.rb +113 -0
  190. data/test/integration/blob/create_blob_snapshot_test.rb +80 -0
  191. data/test/integration/blob/create_page_blob_test.rb +83 -0
  192. data/test/integration/blob/delete_blob_test.rb +159 -0
  193. data/test/integration/blob/get_blob_test.rb +65 -0
  194. data/test/integration/blob/informative_errors_test.rb +39 -0
  195. data/test/integration/blob/lease/acquire_lease_test.rb +36 -0
  196. data/test/integration/blob/lease/break_lease_test.rb +40 -0
  197. data/test/integration/blob/lease/release_lease_test.rb +40 -0
  198. data/test/integration/blob/lease/renew_lease_test.rb +42 -0
  199. data/test/integration/blob/list_blobs_test.rb +113 -0
  200. data/test/integration/cloud_service/Cloud_Create_test.rb +45 -0
  201. data/test/integration/cloud_service/Cloud_Delete_test.rb +45 -0
  202. data/test/integration/database/create_sql_server_firewall_test.rb +86 -0
  203. data/test/integration/database/create_sql_server_test.rb +53 -0
  204. data/test/integration/database/delete_sql_server_firewall_test.rb +70 -0
  205. data/test/integration/database/delete_sql_server_test.rb +58 -0
  206. data/test/integration/database/list_sql_server_firewall_test.rb +45 -0
  207. data/test/integration/database/list_sql_servers_test.rb +44 -0
  208. data/test/integration/database/reset_password_sql_server_test.rb +55 -0
  209. data/test/integration/location/Location_List_test.rb +39 -0
  210. data/test/integration/location/RoleSize_List_test.rb +35 -0
  211. data/test/integration/queue/clear_messages_test.rb +42 -0
  212. data/test/integration/queue/create_message_test.rb +75 -0
  213. data/test/integration/queue/create_queue_test.rb +50 -0
  214. data/test/integration/queue/delete_message_test.rb +67 -0
  215. data/test/integration/queue/delete_queue_test.rb +45 -0
  216. data/test/integration/queue/informative_errors_test.rb +42 -0
  217. data/test/integration/queue/list_messages_encoded_test.rb +79 -0
  218. data/test/integration/queue/list_messages_test.rb +79 -0
  219. data/test/integration/queue/list_queues_test.rb +44 -0
  220. data/test/integration/queue/peek_messages_test.rb +59 -0
  221. data/test/integration/queue/queue_gb18030_test.rb +131 -0
  222. data/test/integration/queue/queue_metadata_test.rb +40 -0
  223. data/test/integration/queue/update_message_test.rb +74 -0
  224. data/test/integration/service_bus/informative_errors_test.rb +37 -0
  225. data/test/integration/service_bus/queues_scenario_test.rb +200 -0
  226. data/test/integration/service_bus/queues_test.rb +266 -0
  227. data/test/integration/service_bus/relay_test.rb +132 -0
  228. data/test/integration/service_bus/rules_test.rb +145 -0
  229. data/test/integration/service_bus/sb_queue_gb18030_test.rb +182 -0
  230. data/test/integration/service_bus/scenario_test.rb +101 -0
  231. data/test/integration/service_bus/subscriptions_test.rb +211 -0
  232. data/test/integration/service_bus/topics_scenario_test.rb +406 -0
  233. data/test/integration/service_bus/topics_test.rb +129 -0
  234. data/test/integration/storage_management/storage_management_test.rb +185 -0
  235. data/test/integration/table/create_table_test.rb +36 -0
  236. data/test/integration/table/delete_entity_batch_test.rb +107 -0
  237. data/test/integration/table/delete_entity_test.rb +94 -0
  238. data/test/integration/table/delete_table_test.rb +40 -0
  239. data/test/integration/table/get_table_test.rb +37 -0
  240. data/test/integration/table/informative_errors_test.rb +39 -0
  241. data/test/integration/table/insert_entity_batch_test.rb +100 -0
  242. data/test/integration/table/insert_entity_test.rb +88 -0
  243. data/test/integration/table/insert_or_merge_entity_batch_test.rb +159 -0
  244. data/test/integration/table/insert_or_merge_entity_test.rb +143 -0
  245. data/test/integration/table/insert_or_replace_entity_batch_test.rb +152 -0
  246. data/test/integration/table/insert_or_replace_entity_test.rb +137 -0
  247. data/test/integration/table/merge_entity_batch_test.rb +128 -0
  248. data/test/integration/table/merge_entity_test.rb +113 -0
  249. data/test/integration/table/query_entities_test.rb +195 -0
  250. data/test/integration/table/query_tables_test.rb +43 -0
  251. data/test/integration/table/query_test.rb +251 -0
  252. data/test/integration/table/table_acl_test.rb +52 -0
  253. data/test/integration/table/table_gb18030_test.rb +355 -0
  254. data/test/integration/table/update_entity_batch_test.rb +149 -0
  255. data/test/integration/table/update_entity_test.rb +131 -0
  256. data/test/integration/test_helper.rb +38 -0
  257. data/test/integration/vm/VM_Create_test.rb +262 -0
  258. data/test/integration/vm/VM_Delete_test.rb +53 -0
  259. data/test/integration/vm/VM_Operations_test.rb +172 -0
  260. data/test/integration/vm_image/virtual_machine_disk_test.rb +37 -0
  261. data/test/integration/vm_image/virtual_machine_image_test.rb +37 -0
  262. data/test/integration/vnet/Virtual_Network_Create_test.rb +116 -0
  263. data/test/integration/vnet/Virtual_Network_list_test.rb +48 -0
  264. data/test/support/env.rb +19 -0
  265. data/test/support/fixtures.rb +36 -0
  266. data/test/support/name_generator.rb +168 -0
  267. data/test/support/stubs.rb +42 -0
  268. data/test/support/virtual_machine_name_generator.rb +102 -0
  269. data/test/support/virtual_network_helper.rb +73 -0
  270. data/test/test_helper.rb +44 -0
  271. data/test/unit/affinity_group/affinity_group_test.rb +189 -0
  272. data/test/unit/affinity_group/serialization_test.rb +87 -0
  273. data/test/unit/base_management/location_test.rb +56 -0
  274. data/test/unit/base_management/role_size_test.rb +50 -0
  275. data/test/unit/blob/auth/shared_access_signature_test.rb +71 -0
  276. data/test/unit/blob/blob_service_test.rb +1969 -0
  277. data/test/unit/cloud_service_management/cloud_service_management_service_test.rb +94 -0
  278. data/test/unit/cloud_service_management/serialization_test.rb +169 -0
  279. data/test/unit/core/auth/shared_key_lite_test.rb +51 -0
  280. data/test/unit/core/auth/shared_key_test.rb +58 -0
  281. data/test/unit/core/auth/signer_test.rb +30 -0
  282. data/test/unit/core/http/http_error_test.rb +62 -0
  283. data/test/unit/core/http/http_request_test.rb +113 -0
  284. data/test/unit/core/http/http_response_test.rb +45 -0
  285. data/test/unit/core/http/retry_policy_test.rb +23 -0
  286. data/test/unit/core/utility_test.rb +122 -0
  287. data/test/unit/database/serialization_test.rb +97 -0
  288. data/test/unit/database/sql_database_server_service_test.rb +284 -0
  289. data/test/unit/service/serialization_test.rb +533 -0
  290. data/test/unit/service/storage_service_test.rb +293 -0
  291. data/test/unit/storage_management/serialization_test.rb +244 -0
  292. data/test/unit/storage_management/storage_management_service_test.rb +247 -0
  293. data/test/unit/table/edmtype_test.rb +108 -0
  294. data/test/unit/virtual_machine_image_management/serialization_test.rb +50 -0
  295. data/test/unit/virtual_machine_image_management/virtual_machine_image_management_service_test.rb +114 -0
  296. data/test/unit/virtual_machine_management/serialization_test.rb +316 -0
  297. data/test/unit/virtual_machine_management/virtual_machine_management_service_test.rb +478 -0
  298. data/test/unit/vnet/serialization_test.rb +187 -0
  299. data/test/unit/vnet/virtual_network_management_service_test.rb +131 -0
  300. metadata +512 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6bd5e1d22edfe62b4067bdc6ef91ab8d16f82708
4
+ data.tar.gz: fc6533c8e01e34346be9e0ad16e700d34eae0378
5
+ SHA512:
6
+ metadata.gz: 936ef4988f1aef8280a5a6f2c930ee8bc2dfaa42652d8cc2543dfb9bba9ab8db616bbf0e7ada42e54d0b8f5208fe90e4aee1a26294dc3a80b4d19daac8e72604
7
+ data.tar.gz: 4807b66899a4cf35ad0c55f1eafb445e8d4143b5cb4314d434b71c008afdbbbcad6daadfb982218d0dc6df896cdd530706ef9b5250ef980d4bfd97eea0fb66c1
@@ -0,0 +1,11 @@
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"
@@ -0,0 +1,15 @@
1
+ .rvmrc
2
+ tags
3
+ /pkg
4
+ /doc
5
+ Gemfile.lock
6
+ nbproject/*
7
+ *.gem
8
+ .idea/*
9
+ .project
10
+
11
+
12
+ .DS_Store
13
+ .ruby-version
14
+ .env
15
+ *.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 [yyyy] [name of copyright owner]
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,630 @@
1
+ # Gem: juliusl-azure-sdk-for-ruby
2
+ This is a fork of the official azure sdk for ruby for development purposes.
3
+
4
+ # Microsoft Azure SDK for Ruby
5
+ [![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)
6
+
7
+
8
+ This project provides a Ruby package that makes it easy to access and manage Microsoft Azure Services like Storage, Service Bus and Virtual Machines.
9
+
10
+ # Library Features
11
+ * Storage
12
+ * Blobs
13
+ * create, list, and delete containers, work with container metadata and permissions, list blobs in container
14
+ * create block and page blobs (from a stream, a file, or a string), work with blob blocks and pages, delete blobs
15
+ * work with blob properties, metadata, leases, snapshot a blob
16
+ * Tables
17
+ * create and delete tables
18
+ * create, query, insert, update, merge, and delete entities
19
+ * Queues
20
+ * create, list, and delete queues, and work with queue metadata
21
+ * create, get, peek, update, delete messages
22
+ * Service Bus
23
+ * Queues
24
+ * create, list and delete queues
25
+ * send, receive, unlock and delete messages
26
+ * Topics
27
+ * create, list, and delete topics
28
+ * send, receive, unlock and delete messages
29
+ * create, list, and delete subscriptions
30
+ * create, list, and delete rules
31
+ * Base Management
32
+ * list locations
33
+ * get, list, create, update, delete affinity groups
34
+ * Virtual Machine Management
35
+ * list images
36
+ * list, delete Disks
37
+ * Virtual Machines
38
+ * create linux based VMs and ssh with cert and key option enabled for ssh and WINRM (both http & https)enabled for windows based VMs
39
+ * list, shut down, delete, find virtual machine deployments. While shutting down your VMs the provisioning state would be deallocated and this VM will not be included in the billing cycle.
40
+ * Create VM for a specific virtual network
41
+ * Cloud Service Management
42
+ * create, list, delete cloud services
43
+ * Storage Account Management
44
+ * create, list storage accounts, list locations
45
+ * SQL Database Server Management
46
+ * list, create SQL Database servers
47
+ * reset password for a SQL Database server
48
+ * list, set, delete firewall rules for a SQL Database server
49
+ * Virtual Network Management
50
+ * List VNet
51
+ * Create VNet via parameters or xml file
52
+
53
+ # Supported Ruby Versions
54
+
55
+ * Ruby 1.9.3
56
+ * Ruby 2.0
57
+ * Ruby 2.1
58
+ * Ruby 2.2
59
+
60
+ # Getting Started
61
+
62
+ ## Install the rubygem package
63
+
64
+ You can install the azure rubygem package directly.
65
+
66
+ ```bash
67
+ gem install azure
68
+ ```
69
+
70
+ ## Download Source Code
71
+
72
+ To get the source code of the SDK via **git** just type:
73
+
74
+ ```bash
75
+ git clone https://github.com/Azure/azure-sdk-for-ruby.git
76
+ cd ./azure-sdk-for-ruby
77
+ ```
78
+ Then, run bundler to install all the gem dependencies:
79
+
80
+ ```bash
81
+ bundle install
82
+ ```
83
+
84
+ ## Generate Documentation
85
+
86
+ Running the command ``rdoc`` will generate the API documentation in the `./doc` directory.
87
+
88
+ ## Setup Connection
89
+
90
+ 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).
91
+
92
+ There are two ways you can set up the connections:
93
+
94
+ 1. [via code](#via-code)
95
+ 2. [via environment variables](#via-environment-variables)
96
+
97
+ ### Via Code
98
+ * Against Microsoft Azure Services in the cloud
99
+
100
+ ```ruby
101
+ require "azure"
102
+
103
+ Azure.configure do |config|
104
+ # Configure these 2 properties to use Storage
105
+ config.storage_account_name = "<your azure storage account name>"
106
+ config.storage_access_key = "<your azure storage access key>"
107
+ # Configure these 3 properties to use Service Bus
108
+ config.sb_namespace = "<your azure service bus namespace>"
109
+ config.sb_access_key = "<your azure service bus access key>"
110
+ config.sb_issuer = "<your azure service bus issuer>"
111
+ # Configure these 3 properties to use Service Management. We support passwordless pfx & pem cert formats.
112
+ config.management_certificate = "<path to your *.pem or *.pfx>"
113
+ config.subscription_id = "<your Subscriptionid>"
114
+ config.management_endpoint = "https://management.core.windows.net"
115
+ # This property enables/disables SQL Server authentication. By default SQL Server authentication is enabled. SQL Server authentication will also be enabled if you do not set this property
116
+ config.sql_database_authentication_mode = <:management_certificate or :sql_server>
117
+ # Configure SQL Server authentication API endpoint here
118
+ config.sql_database_management_endpoint = "http://management.database.windows.net:8443"
119
+ # Configure a ca_cert.pem file if you are having issues with ssl peer verification
120
+ config.ca_file = "./ca_file.pem"
121
+ end
122
+ ```
123
+ * Against local Emulator (Windows Only)
124
+ ```ruby
125
+ require "azure"
126
+
127
+ Azure.configure do |config|
128
+ # Configure these 2 properties to use local Storage Emulator
129
+ config.storage_account_name = "devstoreaccount1"
130
+ config.storage_access_key = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
131
+ config.storage_blob_host = "http://127.0.0.1:10000/devstoreaccount1"
132
+ config.storage_queue_host = "http://127.0.0.1:10001/devstoreaccount1"
133
+ config.storage_table_host = "http://127.0.0.1:10002/devstoreaccount1"
134
+ # Local Service Bus Emulator is not supported
135
+ # Local Service Management emulation is not supported
136
+ end
137
+ ```
138
+ ### Via Environment Variables
139
+ * Against Microsoft Azure Services in the cloud
140
+ * Storage
141
+
142
+ ```bash
143
+ AZURE_STORAGE_ACCOUNT = <your azure storage account name>
144
+ AZURE_STORAGE_ACCESS_KEY = <your azure storage access key>
145
+ ```
146
+ * Service Bus
147
+
148
+ ```bash
149
+ AZURE_SERVICEBUS_NAMESPACE = <your azure service bus namespace>
150
+ AZURE_SERVICEBUS_ACCESS_KEY = <your azure service bus access key>
151
+ AZURE_SERVICEBUS_ISSUER = <your azure service bus issuer>
152
+ ```
153
+ * Service Management
154
+
155
+ ```bash
156
+ AZURE_MANAGEMENT_CERTIFICATE = <path to *.pem or *.pfx>
157
+ AZURE_SUBSCRIPTION_ID = <your subscription ID>
158
+ AZURE_MANAGEMENT_ENDPOINT = <The endpoint URL of Microsoft Azure management service>
159
+ AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT = <SQL Database Management Endpoint>
160
+ AZURE_SQL_DATABASE_AUTHENTICATION_MODE = <:management_certificate or :sql_server>
161
+ ```
162
+
163
+ * [SSL Certificate File](https://gist.github.com/fnichol/867550)
164
+ ```bash
165
+ SSL_CERT_FILE=<path to *.pem>
166
+ ```
167
+ * Against local Emulator (Windows Only)
168
+ * Storage
169
+
170
+ ```bash
171
+ AZURE_STORAGE_ACCOUNT = devstoreaccount1
172
+ AZURE_STORAGE_ACCESS_KEY = Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
173
+ AZURE_STORAGE_BLOB_HOST = http://127.0.0.1:10000/devstoreaccount1
174
+ AZURE_STORAGE_QUEUE_HOST = http://127.0.0.1:10001/devstoreaccount1
175
+ AZURE_STORAGE_TABLE_HOST = http://127.0.0.1:10002/devstoreaccount1
176
+ ```
177
+ * Service Bus: not supported
178
+ * Service Management: not supported
179
+ ## Run Test
180
+ You can use the following commands to run:
181
+ * all the tests: ``rake test``
182
+ * a specific suite of tests: ``rake test:integration:blob``
183
+ * one particular test file: ``ruby -I"lib:test" "<path of the test file>"``
184
+ # Usage
185
+ **For more examples, please see the [Microsoft Azure Ruby Developer Center](http://www.azure.com/en-us/develop/ruby)**
186
+ ## Storage
187
+
188
+ ### Blobs
189
+
190
+ ```ruby
191
+ # Require the azure rubygem
192
+ require "azure"
193
+
194
+ # Create an azure storage blob service object
195
+ azure_blob_service = Azure::BlobService.new
196
+
197
+ # Create a container
198
+ container = azure_blob_service.create_container("test-container")
199
+
200
+ # Upload a Blob
201
+ content = File.open('test.jpg', 'rb') { |file| file.read }
202
+ azure_blob_service.create_block_blob(container.name, "image-blob", content)
203
+
204
+ # List containers
205
+ azure_blob_service.list_containers()
206
+
207
+ # List Blobs
208
+ azure_blob_service.list_blobs(container.name)
209
+
210
+ # Download a Blob
211
+ blob, content = azure_blob_service.get_blob(container.name, "image-blob")
212
+ File.open("download.png", "wb") {|f| f.write(content)}
213
+
214
+ # Delete a Blob
215
+ azure_blob_service.delete_blob(container.name, "image-blob")
216
+ ```
217
+ ### Tables
218
+
219
+ ```ruby
220
+ # Require the azure rubygem
221
+ require "azure"
222
+
223
+ # Create an azure storage table service object
224
+ azure_table_service = Azure::TableService.new
225
+
226
+ # Create a table
227
+ azure_table_service.create_table("testtable")
228
+
229
+ # Insert an entity
230
+ entity = { "content" => "test entity", :partition_key => "test-partition-key", :row_key => "1" }
231
+ azure_table_service.insert_entity("testtable", entity)
232
+
233
+ # Get an entity
234
+ result = azure_table_service.get_entity("testtable", "test-partition-key", "1")
235
+
236
+ # Update an entity
237
+ result.properties["content"] = "test entity with updated content"
238
+ azure_table_service.update_entity(result.table, result.properties)
239
+
240
+ # Query entities
241
+ query = { :filter => "content eq 'test entity'" }
242
+ result, token = azure_table_service.query_entities("testtable", query)
243
+
244
+ # Delete an entity
245
+ azure_table_service.delete_entity("testtable", "test-partition-key", "1")
246
+
247
+ # delete a table
248
+ azure_table_service.delete_table("testtable")
249
+ ```
250
+ ### Queues
251
+
252
+ ```ruby
253
+ # Require the azure rubygem
254
+ require "azure"
255
+
256
+ # Create an azure storage queue service object
257
+ azure_queue_service = Azure::QueueService.new
258
+
259
+ # Create a queue
260
+ azure_queue_service.create_queue("test-queue")
261
+
262
+ # Create a message
263
+ azure_queue_service.create_message("test-queue", "test message")
264
+
265
+ # Get one or more messages with setting the visibility timeout
266
+ result = azure_queue_service.list_messages("test-queue", 30, {:number_of_messages => 10})
267
+
268
+ # Get one or more messages without setting the visibility timeout
269
+ result = azure_queue_service.peek_messages("test-queue", {:number_of_messages => 10})
270
+
271
+ # Update a message
272
+ message = azure_queue_service.list_messages("test-queue", 30)
273
+ pop_receipt, time_next_visible = azure_queue_service.update_message("test-queue", message.id, message.pop_receipt, "updated test message", 30)
274
+
275
+ # Delete a message
276
+ message = azure_queue_service.list_messages("test-queue", 30)
277
+ azure_queue_service.delete_message("test-queue", message.id, message.pop_receipt)
278
+
279
+ # Delete a queue
280
+ azure_queue_service.delete_queue("test-queue")
281
+ ```
282
+ ## Service Bus
283
+
284
+ ### Relay
285
+
286
+ ```ruby
287
+ # Require the azure rubygem
288
+ require "azure"
289
+
290
+ # Create an azure service bus object
291
+ azure_service_bus = Azure::ServiceBusService.new
292
+
293
+ # Create a relay endpoint with just the endpoint name
294
+ relay1 = azure_service_bus.create_relay("test-relay-1", { :relay_type => "Http" })
295
+
296
+ # Create a relay endpoint with a relay object
297
+ relay2 = Azure::ServiceBus::Relay.new("test-relay-2")
298
+ relay2.requires_client_authorization = false
299
+ relay2 = azure_service_bus.create_relay(relay2)
300
+
301
+ # Delete a relay endpoint
302
+ azure_service_bus.delete_relay("test-relay2")
303
+ ```
304
+
305
+ ### Queues
306
+
307
+ ```ruby
308
+ # Require the azure rubygem
309
+ require "azure"
310
+
311
+ # Create an azure service bus object
312
+ azure_service_bus = Azure::ServiceBusService.new
313
+
314
+ # Create a queue with just the queue name
315
+ queue1 = azure_service_bus.create_queue("test-queue-1")
316
+
317
+ # Create a queue with a queue object
318
+ queue2 = Azure::ServiceBus::Queue.new("test-queue-2")
319
+ queue2.max_size_in_megabytes = 2048
320
+ queue2 = azure_service_bus.create_queue(queue2)
321
+
322
+ # Send a queue message with just the message body
323
+ azure_service_bus.send_queue_message("test-queue-1", "test queue message")
324
+
325
+ # Send a queue message with a brokered message object
326
+ message = Azure::ServiceBus::BrokeredMessage.new("another test queue message")
327
+ message.correlation_id = "test-correlation-id-1"
328
+ azure_service_bus.send_queue_message("test-queue-1", message)
329
+
330
+ # Receive a queue message
331
+ message = azure_service_bus.receive_queue_message("test-queue-1")
332
+
333
+ # Delete a queue message
334
+ azure_service_bus.delete_queue_message(message)
335
+
336
+ # Delete a queue
337
+ azure_service_bus.delete_queue("test-queue-1")
338
+ ```
339
+
340
+ ### Topics
341
+
342
+ ```ruby
343
+ # Require the azure rubygem
344
+ require "azure"
345
+
346
+ # Create an azure service bus object
347
+ azure_service_bus = Azure::ServiceBusService.new
348
+
349
+ # Create a topic with just the topic name
350
+ topic1 = azure_service_bus.create_topic("test-topic-1")
351
+
352
+ # Create a topic with a topic object
353
+ topic2 = Azure::ServiceBus::Topic.new("test-topic-2")
354
+ topic2.max_size_in_megabytes = 2048
355
+ topic2 = azure_service_bus.create_topic(topic2)
356
+
357
+ # Create a subscription
358
+ subscription = Azure::ServiceBus::Subscription.new("test-subscription-1")
359
+ subscription.topic = topic1.name
360
+ subscription = azure_service_bus.create_subscription(subscription)
361
+
362
+ # Send a topic message with just the message body
363
+ azure_service_bus.send_topic_message(topic1, "test topic message")
364
+
365
+ # Send a topic message with a brokered message object
366
+ message = Azure::ServiceBus::BrokeredMessage.new("another test topic message")
367
+ message.correlation_id = "test-correlation-id-1"
368
+ azure_service_bus.send_topic_message(topic1, message)
369
+
370
+ # Receive a subscription message
371
+ message = azure_service_bus.receive_subscription_message(topic1.name, subscription.name)
372
+
373
+ # Delete a subscription message
374
+ azure_service_bus.delete_subscription_message(message)
375
+
376
+ # Delete a subscription
377
+ azure_service_bus.delete_subscription(subscription)
378
+
379
+ # Delete a topic
380
+ azure_service_bus.delete_topic(topic1)
381
+ ```
382
+ ## Virtual Machine Management
383
+
384
+ ```ruby
385
+ # Require the azure rubygem
386
+ require 'azure'
387
+
388
+ Azure.configure do |config|
389
+ # Configure these 3 properties to use Storage
390
+ config.management_certificate = "path to *.pem or *.pfx file"
391
+ config.subscription_id = "your subscription id"
392
+ config.management_endpoint = "https://management.core.windows.net"
393
+ end
394
+
395
+ #Create a virtual machine service object
396
+ virtual_machine_service = Azure::VirtualMachineManagementService.new
397
+
398
+ #Get a list of existing virtual machines in your subscription
399
+ virtual_machine_service.list_virtual_machines
400
+
401
+ #API to shutdown Virtual Machine
402
+ virtual_machine_service.shutdown_virtual_machine('vm_name', 'cloud_service_name')
403
+
404
+ #API to start Virtual Machine
405
+ virtual_machine_service.start_virtual_machine('vm_name', 'cloud_service_name')
406
+
407
+ #API to restart Virtual Machine
408
+ virtual_machine_service.restart_virtual_machine('vm_name', 'cloud_service_name')
409
+
410
+ #API for add disk to Virtual Machine
411
+ options = {
412
+ :disk_label => 'disk-label',
413
+ :disk_size => 100, #In GB
414
+ :import => false,
415
+ :disk_name => 'Disk name' #Required when import is true
416
+ }
417
+ virtual_machine_service.add_data_disk('vm_name', 'cloud_service_name', options)
418
+
419
+ #API to add/update Virtual Machine endpoints
420
+ endpoint1 = {
421
+ :name => 'ep-1',
422
+ :public_port => 996,
423
+ :local_port => 998,
424
+ :protocol => 'TCP',
425
+ }
426
+ endpoint2 = {
427
+ :name => 'ep-2',
428
+ :public_port => 997,
429
+ :local_port => 997,
430
+ :protocol => 'TCP',
431
+ :load_balancer_name => ‘lb-ep2’,
432
+ :load_balancer => {:protocol => 'http', :path => 'hello'}
433
+ }
434
+ virtual_machine_service.update_endpoints('vm_name', 'cloud_service_name', endpoint1, endpoint2)
435
+
436
+ #API to delete Virtual Machine endpoint
437
+ virtual_machine_service.delete_endpoint('vm_name', 'cloud_service_name', 'endpoint_name')
438
+
439
+ #API to delete Virtual Machine
440
+ virtual_machine_service.delete_virtual_machine('vm_name', 'cloud_service_name')
441
+
442
+ #API to start deployment
443
+ params = {
444
+ :vm_name => 'vm_name',
445
+ :vm_user => 'azureuser',
446
+ :image => '5112500ae3b842c8b9c604889f8753c3__OpenLogic-CentOS-63APR20130415',
447
+ :password => 'Password',
448
+ :location => 'West US'
449
+ }
450
+ options = {
451
+ :storage_account_name => 'storage_suse',
452
+ :winrm_transport => ['https','http'], #Currently http is supported. To enable https, set the transport protocol to https, simply rdp to the VM once VM is in ready state, export the certificate ( CN name would be the deployment name) from the certstore of the VM and install to your local machine and communicate WinRM via https.
453
+ :cloud_service_name => 'cloud_service_name',
454
+ :deployment_name =>'vm_name',
455
+ :tcp_endpoints => '80,3389:3390',
456
+ :private_key_file => 'c:/private_key.key', #required for ssh or winrm(https) certificate.
457
+ :ssh_port => 2222,
458
+ :vm_size => 'Small', #valid choices are (Basic_A0,Basic_A1,Basic_A2,Basic_A3,Basic_A4,ExtraSmall,Small,Medium,Large,ExtraLarge,A5,A6,A7,A8,A9,Standard_D1,Standard_D2,Standard_D3,Standard_D4,Standard_D11,Standard_D12,Standard_D13,Standard_D14,Standard_DS1,Standard_DS2,Standard_DS3,Standard_DS4,Standard_DS11,Standard_DS12,Standard_DS13,Standard_DS14,Standard_G1,Standard_G2,Standard_G3,Standard_G4,Standard_G5)
459
+ :affinity_group_name => 'affinity1',
460
+ :virtual_network_name => 'xplattestvnet',
461
+ :subnet_name => 'subnet1',
462
+ :availability_set_name => 'availabiltyset1'
463
+ :reserved_ip_name => 'reservedipname'
464
+ }
465
+ virtual_machine_service.create_virtual_machine(params,options)
466
+
467
+ #API usage to add new roles under cloud service creating VM
468
+ #API add_role create multiple roles under the same cloud service. Atleast a single deployment should be created under a hosted service.
469
+ params = {
470
+ :vm_name => 'vm_name',
471
+ :cloud_service_name => 'cloud_service_name',
472
+ :vm_user => 'azureuser',
473
+ :image => 'a699494373c04fc0bc8f2bb1389d6106__Win2K8R2SP1-Datacenter-201305.01-en.us-127GB.vhd',
474
+ :password => 'ComplexPassword',
475
+ }
476
+ options = {
477
+ :storage_account_name => 'storage_suse',
478
+ :winrm_transport => ['https','http'], #Currently http is supported. To enable https, set the transport protocol to https, simply rdp to the VM once VM is in ready state, export the certificate ( CN name would be the deployment name) from the certstore of the VM and install to your local machine and communicate WinRM via https.
479
+ :tcp_endpoints => '80,3389:3390',
480
+ :private_key_file => 'c:/private_key.key', #required for ssh or winrm(https) certificate.
481
+ :winrm_https_port => 5999,
482
+ :winrm_http_port => 6999, #Used to open different powershell port
483
+ :vm_size => 'Small', #valid choices are (Basic_A0,Basic_A1,Basic_A2,Basic_A3,Basic_A4,ExtraSmall,Small,Medium,Large,ExtraLarge,A5,A6,A7,A8,A9,Standard_D1,Standard_D2,Standard_D3,Standard_D4,Standard_D11,Standard_D12,Standard_D13,Standard_D14,Standard_DS1,Standard_DS2,Standard_DS3,Standard_DS4,Standard_DS11,Standard_DS12,Standard_DS13,Standard_DS14,Standard_G1,Standard_G2,Standard_G3,Standard_G4,Standard_G5)
484
+ :availability_set_name => 'availabiltyset'
485
+ }
486
+ virtual_machine_service.add_role(params, options)
487
+
488
+ #Get a list of available virtual machine images
489
+ virtual_machine_image_service = Azure::VirtualMachineImageManagementService.new
490
+ virtual_machine_image_service.list_virtual_machine_images
491
+
492
+ #Get a list of available regional data center locations
493
+ base_management = Azure::BaseManagementService.new
494
+ base_management.list_locations
495
+ ```
496
+ ## Affinity Group Management
497
+
498
+ ```ruby
499
+ # Require the azure rubygem
500
+ require 'azure'
501
+
502
+ #Create a affinity group service object
503
+ base_management_service = Azure::BaseManagementService.new
504
+
505
+ #Get a list of affinity group that are provisioned for a subscription.
506
+ base_management_service.list_affinity_groups
507
+
508
+ #API to delete affinity group
509
+ base_management_service.delete_affinity_group('affinity-group-name')
510
+
511
+ #API to add a new affinity group to a subscription
512
+ options = {:description => 'Some Description'}
513
+ base_management_service.create_affinity_group('affinity-group-name', 'West US', 'Label Name', options)
514
+
515
+ #API to update affinity group
516
+ options = {:description => 'Some Description'}
517
+ base_management_service.update_affinity_group('affinity-group-name', 'Label Name', options)
518
+
519
+ #API to list properties associated with the specified affinity group
520
+ base_management_service.get_affinity_group('affinity-group-name')
521
+ ```
522
+ ## SQL Database Server Management
523
+
524
+ ```ruby
525
+ # Require the azure rubygem
526
+ require 'azure'
527
+
528
+ Azure.configure do |config|
529
+ config.management_certificate = "path to *.pem or *.pfx file"
530
+ config.subscription_id = "your subscription id"
531
+ config.management_endpoint = "https://management.database.windows.net:8443/"
532
+ #To access other service management apis use "https://management.core.windows.net".
533
+ end
534
+
535
+ #Create a database server service object
536
+ sql_db_service = Azure::SqlDatabaseManagementService.new
537
+
538
+ #Get a list of SQL Database servers that are provisioned for a subscription.
539
+ sql_db_service.list_servers
540
+
541
+ #API to delete SQL Database server
542
+ sql_db_service.delete_server('server_name')
543
+
544
+ #API to adds a new SQL Database server to a subscription
545
+ sql_db_service.create_server('admin-login', 'ComplexPassword', 'West US')
546
+
547
+ #API to sets the administrative password of a SQL Database server for a subscription
548
+ sql_db_service.reset_password('server-name', 'NewPassword')
549
+
550
+ #Get a list of all the server-level firewall rules for a SQL Database server that belongs to a subscription
551
+ sql_db_service.list_sql_server_firewall_rules("server-name")
552
+
553
+ #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.
554
+ sql_db_service.delete_sql_server_firewall_rule("server-name", "rule-name")
555
+
556
+ #API to add/updates server-level firewall rule for a SQL Database server that belongs to a subscription
557
+ ip_range = {:start_ip_address => "0.0.0.1", :end_ip_address => "0.0.0.5"}
558
+ sql_db_service.set_sql_server_firewall_rule("server-name", "rule-name", ip_range)
559
+
560
+ # 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.
561
+ # To toggle between the option to allow Microsoft Azure services to access db server similar to azure portal just set the fire wall rule
562
+ # with iprange to be 0.0.0.0 as start and end.Remove the rule to unset this option.
563
+ ```
564
+ ## Virtual Network Management
565
+
566
+ ```ruby
567
+ # Require the azure rubygem
568
+ require 'azure'
569
+
570
+ #Create a virtual network service object
571
+
572
+ vnet = Azure::VirtualNetworkManagementService.new
573
+
574
+ #API to get a list of virtual networks created for a subscription.
575
+
576
+ vnet.list_virtual_networks
577
+
578
+ #API to configure virtual network with required and optional parameters
579
+
580
+ address_space = ['172.16.0.0/12', '10.0.0.0/8', '192.168.0.0/24']
581
+
582
+ subnets = [{:name => 'subnet-1', :ip_address=>'172.16.0.0', :cidr=>12}, {:name => 'subnet-2', :ip_address=>'10.0.0.0', :cidr=>8}]
583
+
584
+ dns_servers = [{:name => 'dns-1', :ip_address=>'1.2.3.4'}, {:name => 'dns-2', :ip_address=>'8.7.6.5'}]
585
+
586
+ options = {:subnet => subnets, :dns => dns_servers}
587
+
588
+ vnet.set_network_configuration('virtual-network-name', 'location_name', address_space, options)
589
+
590
+ #API to configure virtual network from xml file that can be exported from management portal and customized to add or delete vnet
591
+
592
+ vnetxml = './customnetwork.xml'
593
+
594
+ vnet.set_network_configuration(vnetxml)
595
+ ```
596
+
597
+ # Useful commands for certificate operations
598
+
599
+ Currently the sdk supports *.pem or *.pfx (passwordless pfx) for service management operations. Following are the steps discussed on various cert operations.
600
+
601
+ ## Publish Settings files
602
+
603
+ * To create a pfx from the publishsettings, simply download the publishsettings file for your subscription
604
+ [https://manage.windowsazure.com/publishsettings](https://manage.windowsazure.com/publishsettings/index?client=powershell). Make sure you have this gem installed and
605
+ run `pfxer --in [path to your .publishsettings file]`. This will create a .pfx from your publish settings file which can
606
+ be supplied as a cert parameter for Service Management Commands.
607
+
608
+ ## Generate New Cert and Upload to Azure Portal
609
+
610
+ * Using the following openssl commands to create a cert and upload to Azure Management
611
+ * Generate public and private `openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.key -out mycert.pem`
612
+ * Generate public .cer for Azure upload `openssl x509 -inform pem -in mycert.pem -outform der -out mycert_mgmt.cer`
613
+ * Upload the `mycert_mgmt.cer` to Azure Management through [https://management.azure.com](https://management.azure.com)
614
+ * Combine the public and private into one `cat mycert.key mycert.pem > cert.pem`
615
+ * Use cert.pem as your cert parameter for Service Management Commands.
616
+
617
+ # Need Help?
618
+
619
+ Be sure to check out the Microsoft Azure [Developer Forums on Stack Overflow and MSDN](http://go.microsoft.com/fwlink/?LinkId=234489) if you have trouble with the provided code.
620
+
621
+ # Contribute Code or Provide Feedback
622
+
623
+ If you would like to become an active contributor to this project please follow the instructions provided in [Microsoft Azure Projects Contribution Guidelines](http://azure.github.com/guidelines.html).
624
+ 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.
625
+
626
+ # Learn More
627
+
628
+ For documentation on how to host Ruby applications on Microsoft Azure, please see the [Microsoft Azure Ruby Developer Center](http://www.azure.com/en-us/develop/ruby/).
629
+ For documentation on Azure PowerShell CLI tool for Windows, please see our readme [here](http://github.com/azure/azure-sdk-tools).
630
+ For documentation on the Azure cross platform CLI tool for Windows, Mac and Linux, please see our readme [here](http://github.com/azure/azure-sdk-tools-xplat).