azure.rst 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  1. ==========================
  2. Getting Started With Azure
  3. ==========================
  4. .. versionadded:: 2014.1.0
  5. Azure is a cloud service by Microsoft providing virtual machines, SQL services,
  6. media services, and more. This document describes how to use Salt Cloud to
  7. create a virtual machine on Azure, with Salt installed.
  8. More information about Azure is located at `http://www.windowsazure.com/
  9. <http://www.windowsazure.com/>`_.
  10. Dependencies
  11. ============
  12. * `Microsoft Azure SDK for Python <https://pypi.python.org/pypi/azure/1.0.2>`_ >= 1.0.2
  13. * The python-requests library, for Python < 2.7.9.
  14. * A Microsoft Azure account
  15. * OpenSSL (to generate the certificates)
  16. * `Salt <https://github.com/saltstack/salt>`_
  17. Configuration
  18. =============
  19. Set up the provider config at ``/etc/salt/cloud.providers.d/azure.conf``:
  20. .. code-block:: yaml
  21. # Note: This example is for /etc/salt/cloud.providers.d/azure.conf
  22. my-azure-config:
  23. driver: azure
  24. subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
  25. certificate_path: /etc/salt/azure.pem
  26. # Set up the location of the salt master
  27. #
  28. minion:
  29. master: saltmaster.example.com
  30. # Optional
  31. management_host: management.core.windows.net
  32. The certificate used must be generated by the user. OpenSSL can be used to
  33. create the management certificates. Two certificates are needed: a .cer file,
  34. which is uploaded to Azure, and a .pem file, which is stored locally.
  35. To create the .pem file, execute the following command:
  36. .. code-block:: bash
  37. openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/salt/azure.pem -out /etc/salt/azure.pem
  38. To create the .cer file, execute the following command:
  39. .. code-block:: bash
  40. openssl x509 -inform pem -in /etc/salt/azure.pem -outform der -out /etc/salt/azure.cer
  41. After creating these files, the .cer file will need to be uploaded to
  42. Azure via the "Upload a Management Certificate" action of the "Management Certificates"
  43. tab within the "Settings" section of the management portal.
  44. Optionally, a ``management_host`` may be configured, if necessary for the region.
  45. .. note::
  46. .. versionchanged:: 2015.8.0
  47. The ``provider`` parameter in cloud provider definitions was renamed to ``driver``. This
  48. change was made to avoid confusion with the ``provider`` parameter that is used in cloud profile
  49. definitions. Cloud provider definitions now use ``driver`` to refer to the Salt cloud module that
  50. provides the underlying functionality to connect to a cloud host, while cloud profiles continue
  51. to use ``provider`` to refer to provider configurations that you define.
  52. Cloud Profiles
  53. ==============
  54. Set up an initial profile at ``/etc/salt/cloud.profiles``:
  55. .. code-block:: yaml
  56. azure-ubuntu:
  57. provider: my-azure-config
  58. image: 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20131003-en-us-30GB'
  59. size: Small
  60. location: 'East US'
  61. ssh_username: azureuser
  62. ssh_password: verybadpass
  63. slot: production
  64. media_link: 'http://portalvhdabcdefghijklmn.blob.core.windows.net/vhds'
  65. virtual_network_name: azure-virtual-network
  66. subnet_name: azure-subnet
  67. These options are described in more detail below. Once configured, the profile
  68. can be realized with a salt command:
  69. .. code-block:: bash
  70. salt-cloud -p azure-ubuntu newinstance
  71. This will create an salt minion instance named ``newinstance`` in Azure. If
  72. the command was executed on the salt-master, its Salt key will automatically
  73. be signed on the master.
  74. Once the instance has been created with salt-minion installed, connectivity to
  75. it can be verified with Salt:
  76. .. code-block:: bash
  77. salt newinstance test.version
  78. Profile Options
  79. ===============
  80. The following options are currently available for Azure.
  81. provider
  82. --------
  83. The name of the provider as configured in
  84. `/etc/salt/cloud.providers.d/azure.conf`.
  85. image
  86. -----
  87. The name of the image to use to create a VM. Available images can be viewed
  88. using the following command:
  89. .. code-block:: bash
  90. salt-cloud --list-images my-azure-config
  91. size
  92. ----
  93. The name of the size to use to create a VM. Available sizes can be viewed using
  94. the following command:
  95. .. code-block:: bash
  96. salt-cloud --list-sizes my-azure-config
  97. location
  98. --------
  99. The name of the location to create a VM in. Available locations can be viewed
  100. using the following command:
  101. .. code-block:: bash
  102. salt-cloud --list-locations my-azure-config
  103. affinity_group
  104. --------------
  105. The name of the affinity group to create a VM in. Either a ``location`` or an
  106. ``affinity_group`` may be specified, but not both. See Affinity Groups below.
  107. ssh_username
  108. ------------
  109. The user to use to log into the newly-created VM to install Salt.
  110. ssh_password
  111. ------------
  112. The password to use to log into the newly-created VM to install Salt.
  113. slot
  114. ----
  115. The environment to which the hosted service is deployed. Valid values are
  116. `staging` or `production`. When set to `production`, the resulting URL of the
  117. new VM will be `<vm_name>.cloudapp.net`. When set to `staging`, the resulting
  118. URL will contain a generated hash instead.
  119. media_link
  120. ----------
  121. This is the URL of the container that will store the disk that this VM uses.
  122. Currently, this container must already exist. If a VM has previously been
  123. created in the associated account, a container should already exist. In the web
  124. interface, go into the Storage area and click one of the available storage
  125. selections. Click the Containers link, and then copy the URL from the container
  126. that will be used. It generally looks like:
  127. .. code-block:: yaml
  128. http://portalvhdabcdefghijklmn.blob.core.windows.net/vhds
  129. service_name
  130. ------------
  131. The name of the service in which to create the VM. If this is not specified,
  132. then a service will be created with the same name as the VM.
  133. virtual_network_name
  134. --------------------
  135. Optional. The name of the virtual network for the VM to join. If this is not
  136. specified, then no virtual network will be joined.
  137. subnet_name
  138. ------------
  139. Optional. The name of the subnet in the virtual network for the VM to join.
  140. Requires that a ``virtual_network_name`` is specified.
  141. Show Instance
  142. =============
  143. This action is a thin wrapper around ``--full-query``, which displays details on
  144. a single instance only. In an environment with several machines, this will save
  145. a user from having to sort through all instance data, just to examine a single
  146. instance.
  147. .. code-block:: bash
  148. salt-cloud -a show_instance myinstance
  149. Destroying VMs
  150. ==============
  151. There are certain options which can be specified in the global cloud
  152. configuration file (usually ``/etc/salt/cloud``) which affect Salt Cloud's
  153. behavior when a VM is destroyed.
  154. cleanup_disks
  155. -------------
  156. .. versionadded:: 2015.8.0
  157. Default is ``False``. When set to ``True``, Salt Cloud will wait for the VM to
  158. be destroyed, then attempt to destroy the main disk that is associated with the
  159. VM.
  160. cleanup_vhds
  161. ------------
  162. .. versionadded:: 2015.8.0
  163. Default is ``False``. Requires ``cleanup_disks`` to be set to ``True``. When
  164. also set to ``True``, Salt Cloud will ask Azure to delete the VHD associated
  165. with the disk that is also destroyed.
  166. cleanup_services
  167. ----------------
  168. .. versionadded:: 2015.8.0
  169. Default is ``False``. Requires ``cleanup_disks`` to be set to ``True``. When
  170. also set to ``True``, Salt Cloud will wait for the disk to be destroyed, then
  171. attempt to remove the service that is associated with the VM. Because the disk
  172. belongs to the service, the disk must be destroyed before the service can be.
  173. Managing Hosted Services
  174. ========================
  175. .. versionadded:: 2015.8.0
  176. An account can have one or more hosted services. A hosted service is required
  177. in order to create a VM. However, as mentioned above, if a hosted service is not
  178. specified when a VM is created, then one will automatically be created with the
  179. name of the name. The following functions are also available.
  180. create_service
  181. --------------
  182. Create a hosted service. The following options are available.
  183. name
  184. ~~~~
  185. Required. The name of the hosted service to create.
  186. label
  187. ~~~~~
  188. Required. A label to apply to the hosted service.
  189. description
  190. ~~~~~~~~~~~
  191. Optional. A longer description of the hosted service.
  192. location
  193. ~~~~~~~~
  194. Required, if ``affinity_group`` is not set. The location in which to create the
  195. hosted service. Either the ``location`` or the ``affinity_group`` must be set,
  196. but not both.
  197. affinity_group
  198. ~~~~~~~~~~~~~~
  199. Required, if ``location`` is not set. The affinity group in which to create the
  200. hosted service. Either the ``location`` or the ``affinity_group`` must be set,
  201. but not both.
  202. extended_properties
  203. ~~~~~~~~~~~~~~~~~~~
  204. Optional. Dictionary containing name/value pairs of hosted service properties.
  205. You can have a maximum of 50 extended property name/value pairs. The maximum
  206. length of the Name element is 64 characters, only alphanumeric characters and
  207. underscores are valid in the Name, and the name must start with a letter.
  208. The value has a maximum length of 255 characters.
  209. CLI Example
  210. ~~~~~~~~~~~
  211. The following example illustrates creating a hosted service.
  212. .. code-block:: bash
  213. salt-cloud -f create_service my-azure name=my-service label=my-service location='West US'
  214. show_service
  215. ------------
  216. Return details about a specific hosted service. Can also be called with
  217. ``get_service``.
  218. .. code-block:: bash
  219. salt-cloud -f show_storage my-azure name=my-service
  220. list_services
  221. -------------
  222. List all hosted services associates with the subscription.
  223. .. code-block:: bash
  224. salt-cloud -f list_services my-azure-config
  225. delete_service
  226. --------------
  227. Delete a specific hosted service.
  228. .. code-block:: bash
  229. salt-cloud -f delete_service my-azure name=my-service
  230. Managing Storage Accounts
  231. =========================
  232. .. versionadded:: 2015.8.0
  233. Salt Cloud can manage storage accounts associated with the account. The
  234. following functions are available. Deprecated marked as deprecated are marked
  235. as such as per the SDK documentation, but are still included for completeness
  236. with the SDK.
  237. create_storage
  238. --------------
  239. Create a storage account. The following options are supported.
  240. name
  241. ~~~~
  242. Required. The name of the storage account to create.
  243. label
  244. ~~~~~
  245. Required. A label to apply to the storage account.
  246. description
  247. ~~~~~~~~~~~
  248. Optional. A longer description of the storage account.
  249. location
  250. ~~~~~~~~
  251. Required, if ``affinity_group`` is not set. The location in which to create the
  252. storage account. Either the ``location`` or the ``affinity_group`` must be set,
  253. but not both.
  254. affinity_group
  255. ~~~~~~~~~~~~~~
  256. Required, if ``location`` is not set. The affinity group in which to create the
  257. storage account. Either the ``location`` or the ``affinity_group`` must be set,
  258. but not both.
  259. extended_properties
  260. ~~~~~~~~~~~~~~~~~~~
  261. Optional. Dictionary containing name/value pairs of storage account properties.
  262. You can have a maximum of 50 extended property name/value pairs. The maximum
  263. length of the Name element is 64 characters, only alphanumeric characters and
  264. underscores are valid in the Name, and the name must start with a letter. The
  265. value has a maximum length of 255 characters.
  266. geo_replication_enabled
  267. ~~~~~~~~~~~~~~~~~~~~~~~
  268. Deprecated. Replaced by the account_type parameter.
  269. account_type
  270. ~~~~~~~~~~~~
  271. Specifies whether the account supports locally-redundant storage, geo-redundant
  272. storage, zone-redundant storage, or read access geo-redundant storage. Possible
  273. values are:
  274. - Standard_LRS
  275. - Standard_ZRS
  276. - Standard_GRS
  277. - Standard_RAGRS
  278. CLI Example
  279. ~~~~~~~~~~~
  280. The following example illustrates creating a storage account.
  281. .. code-block:: bash
  282. salt-cloud -f create_storage my-azure name=my-storage label=my-storage location='West US'
  283. list_storage
  284. ------------
  285. List all storage accounts associates with the subscription.
  286. .. code-block:: bash
  287. salt-cloud -f list_storage my-azure-config
  288. show_storage
  289. ------------
  290. Return details about a specific storage account. Can also be called with
  291. ``get_storage``.
  292. .. code-block:: bash
  293. salt-cloud -f show_storage my-azure name=my-storage
  294. update_storage
  295. --------------
  296. Update details concerning a storage account. Any of the options available in
  297. ``create_storage`` can be used, but the name cannot be changed.
  298. .. code-block:: bash
  299. salt-cloud -f update_storage my-azure name=my-storage label=my-storage
  300. delete_storage
  301. --------------
  302. Delete a specific storage account.
  303. .. code-block:: bash
  304. salt-cloud -f delete_storage my-azure name=my-storage
  305. show_storage_keys
  306. -----------------
  307. Returns the primary and secondary access keys for the specified storage account.
  308. .. code-block:: bash
  309. salt-cloud -f show_storage_keys my-azure name=my-storage
  310. regenerate_storage_keys
  311. -----------------------
  312. Regenerate storage account keys. Requires a key_type ("primary" or "secondary")
  313. to be specified.
  314. .. code-block:: bash
  315. salt-cloud -f regenerate_storage_keys my-azure name=my-storage key_type=primary
  316. Managing Disks
  317. ==============
  318. .. versionadded:: 2015.8.0
  319. When a VM is created, a disk will also be created for it. The following
  320. functions are available for managing disks. Deprecated marked as deprecated are
  321. marked as such as per the SDK documentation, but are still included for
  322. completeness with the SDK.
  323. show_disk
  324. ---------
  325. Return details about a specific disk. Can also be called with ``get_disk``.
  326. .. code-block:: bash
  327. salt-cloud -f show_disk my-azure name=my-disk
  328. list_disks
  329. ----------
  330. List all disks associates with the account.
  331. .. code-block:: bash
  332. salt-cloud -f list_disks my-azure
  333. update_disk
  334. -----------
  335. Update details for a disk. The following options are available.
  336. name
  337. ~~~~
  338. Required. The name of the disk to update.
  339. has_operating_system
  340. ~~~~~~~~~~~~~~~~~~~~
  341. Deprecated.
  342. label
  343. ~~~~~
  344. Required. The label for the disk.
  345. media_link
  346. ~~~~~~~~~~
  347. Deprecated. The location of the disk in the account, including the storage
  348. container that it is in. This should not need to be changed.
  349. new_name
  350. ~~~~~~~~
  351. Deprecated. If renaming the disk, the new name.
  352. os
  353. ~~~
  354. Deprecated.
  355. CLI Example
  356. ~~~~~~~~~~~
  357. The following example illustrates updating a disk.
  358. .. code-block:: bash
  359. salt-cloud -f update_disk my-azure name=my-disk label=my-disk
  360. delete_disk
  361. -----------
  362. Delete a specific disk.
  363. .. code-block:: bash
  364. salt-cloud -f delete_disk my-azure name=my-disk
  365. Managing Service Certificates
  366. =============================
  367. .. versionadded:: 2015.8.0
  368. Stored at the cloud service level, these certificates are used by your deployed
  369. services. For more information on service certificates, see the following link:
  370. * `Manage Certificates`__
  371. .. __: https://docs.microsoft.com/en-us/azure/cloud-services/cloud-services-certs-create
  372. The following functions are available.
  373. list_service_certificates
  374. -------------------------
  375. List service certificates associated with the account.
  376. .. code-block:: bash
  377. salt-cloud -f list_service_certificates my-azure
  378. show_service_certificate
  379. ------------------------
  380. Show the data for a specific service certificate associated with the account.
  381. The ``name``, ``thumbprint``, and ``thumbalgorithm`` can be obtained from
  382. ``list_service_certificates``. Can also be called with
  383. ``get_service_certificate``.
  384. .. code-block:: bash
  385. salt-cloud -f show_service_certificate my-azure name=my_service_certificate \
  386. thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
  387. add_service_certificate
  388. -----------------------
  389. Add a service certificate to the account. This requires that a certificate
  390. already exists, which is then added to the account. For more information on
  391. creating the certificate itself, see:
  392. * `Create a Service Certificate for Azure`__
  393. .. __: https://msdn.microsoft.com/en-us/library/azure/gg432987.aspx
  394. The following options are available.
  395. name
  396. ~~~~
  397. Required. The name of the hosted service that the certificate will belong to.
  398. data
  399. ~~~~
  400. Required. The base-64 encoded form of the pfx file.
  401. certificate_format
  402. ~~~~~~~~~~~~~~~~~~
  403. Required. The service certificate format. The only supported value is pfx.
  404. password
  405. ~~~~~~~~
  406. The certificate password.
  407. .. code-block:: bash
  408. salt-cloud -f add_service_certificate my-azure name=my-cert \
  409. data='...CERT_DATA...' certificate_format=pfx password=verybadpass
  410. delete_service_certificate
  411. --------------------------
  412. Delete a service certificate from the account. The ``name``, ``thumbprint``,
  413. and ``thumbalgorithm`` can be obtained from ``list_service_certificates``.
  414. .. code-block:: bash
  415. salt-cloud -f delete_service_certificate my-azure \
  416. name=my_service_certificate \
  417. thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
  418. Managing Management Certificates
  419. ================================
  420. .. versionadded:: 2015.8.0
  421. A Azure management certificate is an X.509 v3 certificate used to authenticate
  422. an agent, such as Visual Studio Tools for Windows Azure or a client application
  423. that uses the Service Management API, acting on behalf of the subscription owner
  424. to manage subscription resources. Azure management certificates are uploaded to
  425. Azure and stored at the subscription level. The management certificate store can
  426. hold up to 100 certificates per subscription. These certificates are used to
  427. authenticate your Windows Azure deployment.
  428. For more information on management certificates, see the following link.
  429. * `Manage Certificates`__
  430. .. __: https://msdn.microsoft.com/en-us/library/azure/gg981929.aspx
  431. The following functions are available.
  432. list_management_certificates
  433. ----------------------------
  434. List management certificates associated with the account.
  435. .. code-block:: bash
  436. salt-cloud -f list_management_certificates my-azure
  437. show_management_certificate
  438. ---------------------------
  439. Show the data for a specific management certificate associated with the account.
  440. The ``name``, ``thumbprint``, and ``thumbalgorithm`` can be obtained from
  441. ``list_management_certificates``. Can also be called with
  442. ``get_management_certificate``.
  443. .. code-block:: bash
  444. salt-cloud -f show_management_certificate my-azure name=my_management_certificate \
  445. thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
  446. add_management_certificate
  447. --------------------------
  448. Management certificates must have a key length of at least 2048 bits and should
  449. reside in the Personal certificate store. When the certificate is installed on
  450. the client, it should contain the private key of the certificate. To upload to
  451. the certificate to the Microsoft Azure Management Portal, you must export it as
  452. a .cer format file that does not contain the private key. For more information
  453. on creating management certificates, see the following link:
  454. * `Create and Upload a Management Certificate for Azure`__
  455. .. __: https://msdn.microsoft.com/en-us/library/azure/gg551722.aspx
  456. The following options are available.
  457. public_key
  458. ~~~~~~~~~~
  459. A base64 representation of the management certificate public key.
  460. thumbprint
  461. ~~~~~~~~~~
  462. The thumb print that uniquely identifies the management certificate.
  463. data
  464. ~~~~
  465. The certificate's raw data in base-64 encoded .cer format.
  466. .. code-block:: bash
  467. salt-cloud -f add_management_certificate my-azure public_key='...PUBKEY...' \
  468. thumbprint=0123456789ABCDEF data='...CERT_DATA...'
  469. delete_management_certificate
  470. -----------------------------
  471. Delete a management certificate from the account. The ``thumbprint`` can be
  472. obtained from ``list_management_certificates``.
  473. .. code-block:: bash
  474. salt-cloud -f delete_management_certificate my-azure thumbprint=0123456789ABCDEF
  475. Virtual Network Management
  476. ==========================
  477. .. versionadded:: 2015.8.0
  478. The following are functions for managing virtual networks.
  479. list_virtual_networks
  480. ---------------------
  481. List input endpoints associated with the deployment.
  482. .. code-block:: bash
  483. salt-cloud -f list_virtual_networks my-azure service=myservice deployment=mydeployment
  484. Managing Input Endpoints
  485. ========================
  486. .. versionadded:: 2015.8.0
  487. Input endpoints are used to manage port access for roles. Because endpoints
  488. cannot be managed by the Azure Python SDK, Salt Cloud uses the API directly.
  489. With versions of Python before 2.7.9, the ``requests-python`` package needs to
  490. be installed in order for this to work. Additionally, the following needs to be
  491. set in the master's configuration file:
  492. .. code-block:: bash
  493. backend: requests
  494. The following functions are available.
  495. list_input_endpoints
  496. --------------------
  497. List input endpoints associated with the deployment
  498. .. code-block:: bash
  499. salt-cloud -f list_input_endpoints my-azure service=myservice deployment=mydeployment
  500. show_input_endpoint
  501. -------------------
  502. Show an input endpoint associated with the deployment
  503. .. code-block:: bash
  504. salt-cloud -f show_input_endpoint my-azure service=myservice \
  505. deployment=mydeployment name=SSH
  506. add_input_endpoint
  507. ------------------
  508. Add an input endpoint to the deployment. Please note that there may be a delay
  509. before the changes show up. The following options are available.
  510. service
  511. ~~~~~~~
  512. Required. The name of the hosted service which the VM belongs to.
  513. deployment
  514. ~~~~~~~~~~
  515. Required. The name of the deployment that the VM belongs to. If the VM was
  516. created with Salt Cloud, the deployment name probably matches the VM name.
  517. role
  518. ~~~~
  519. Required. The name of the role that the VM belongs to. If the VM was created
  520. with Salt Cloud, the role name probably matches the VM name.
  521. name
  522. ~~~~
  523. Required. The name of the input endpoint. This typically matches the port that
  524. the endpoint is set to. For instance, port 22 would be called SSH.
  525. port
  526. ~~~~
  527. Required. The public (Internet-facing) port that is used for the endpoint.
  528. local_port
  529. ~~~~~~~~~~
  530. Optional. The private port on the VM itself that will be matched with the port.
  531. This is typically the same as the ``port``. If this value is not specified, it
  532. will be copied from ``port``.
  533. protocol
  534. ~~~~~~~~
  535. Required. Either ``tcp`` or ``udp``.
  536. enable_direct_server_return
  537. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  538. Optional. If an internal load balancer exists in the account, it can be used
  539. with a direct server return. The default value is ``False``. Please see the
  540. following article for an explanation of this option.
  541. * `Load Balancing for Azure Infrastructure Services`__
  542. .. __: http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-load-balance/
  543. timeout_for_tcp_idle_connection
  544. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  545. Optional. The default value is ``4``. Please see the following article for an
  546. explanation of this option.
  547. * `Configurable Idle Timeout for Azure Load Balancer`__
  548. .. __: http://azure.microsoft.com/blog/2014/08/14/new-configurable-idle-timeout-for-azure-load-balancer/
  549. CLI Example
  550. ~~~~~~~~~~~
  551. The following example illustrates adding an input endpoint.
  552. .. code-block:: bash
  553. salt-cloud -f add_input_endpoint my-azure service=myservice \
  554. deployment=mydeployment role=myrole name=HTTP local_port=80 \
  555. port=80 protocol=tcp enable_direct_server_return=False \
  556. timeout_for_tcp_idle_connection=4
  557. update_input_endpoint
  558. ---------------------
  559. Updates the details for a specific input endpoint. All options from
  560. ``add_input_endpoint`` are supported.
  561. .. code-block:: bash
  562. salt-cloud -f update_input_endpoint my-azure service=myservice \
  563. deployment=mydeployment role=myrole name=HTTP local_port=80 \
  564. port=80 protocol=tcp enable_direct_server_return=False \
  565. timeout_for_tcp_idle_connection=4
  566. delete_input_endpoint
  567. ---------------------
  568. Delete an input endpoint from the deployment. Please note that there may be a
  569. delay before the changes show up. The following items are required.
  570. CLI Example
  571. ~~~~~~~~~~~
  572. The following example illustrates deleting an input endpoint.
  573. service
  574. ~~~~~~~
  575. The name of the hosted service which the VM belongs to.
  576. deployment
  577. ~~~~~~~~~~
  578. The name of the deployment that the VM belongs to. If the VM was created with
  579. Salt Cloud, the deployment name probably matches the VM name.
  580. role
  581. ~~~~
  582. The name of the role that the VM belongs to. If the VM was created with Salt
  583. Cloud, the role name probably matches the VM name.
  584. name
  585. ~~~~
  586. The name of the input endpoint. This typically matches the port that the
  587. endpoint is set to. For instance, port 22 would be called SSH.
  588. .. code-block:: bash
  589. salt-cloud -f delete_input_endpoint my-azure service=myservice \
  590. deployment=mydeployment role=myrole name=HTTP
  591. Managing Affinity Groups
  592. ========================
  593. .. versionadded:: 2015.8.0
  594. Affinity groups allow you to group your Azure services to optimize performance.
  595. All services and VMs within an affinity group will be located in the same
  596. region. For more information on Affinity groups, see the following link:
  597. * `Create an Affinity Group in the Management Portal`__
  598. .. __: https://msdn.microsoft.com/en-us/library/azure/jj156209.aspx
  599. The following functions are available.
  600. list_affinity_groups
  601. --------------------
  602. List input endpoints associated with the account
  603. .. code-block:: bash
  604. salt-cloud -f list_affinity_groups my-azure
  605. show_affinity_group
  606. -------------------
  607. Show an affinity group associated with the account
  608. .. code-block:: bash
  609. salt-cloud -f show_affinity_group my-azure service=myservice \
  610. deployment=mydeployment name=SSH
  611. create_affinity_group
  612. ---------------------
  613. Create a new affinity group. The following options are supported.
  614. name
  615. ~~~~
  616. Required. The name of the new affinity group.
  617. location
  618. ~~~~~~~~
  619. Required. The region in which the affinity group lives.
  620. label
  621. ~~~~~
  622. Required. A label describing the new affinity group.
  623. description
  624. ~~~~~~~~~~~
  625. Optional. A longer description of the affinity group.
  626. .. code-block:: bash
  627. salt-cloud -f create_affinity_group my-azure name=my_affinity_group \
  628. label=my-affinity-group location='West US'
  629. update_affinity_group
  630. ---------------------
  631. Update an affinity group's properties
  632. .. code-block:: bash
  633. salt-cloud -f update_affinity_group my-azure name=my_group label=my_group
  634. delete_affinity_group
  635. ---------------------
  636. Delete a specific affinity group associated with the account
  637. .. code-block:: bash
  638. salt-cloud -f delete_affinity_group my-azure name=my_affinity_group
  639. Managing Blob Storage
  640. =====================
  641. .. versionadded:: 2015.8.0
  642. Azure storage containers and their contents can be managed with Salt Cloud. This
  643. is not as elegant as using one of the other available clients in Windows, but it
  644. benefits Linux and Unix users, as there are fewer options available on those
  645. platforms.
  646. Blob Storage Configuration
  647. --------------------------
  648. Blob storage must be configured differently than the standard Azure
  649. configuration. Both a ``storage_account`` and a ``storage_key`` must be
  650. specified either through the Azure provider configuration (in addition to the
  651. other Azure configuration) or via the command line.
  652. .. code-block:: yaml
  653. storage_account: mystorage
  654. storage_key: ffhj334fDSGFEGDFGFDewr34fwfsFSDFwe==
  655. storage_account
  656. ~~~~~~~~~~~~~~~
  657. This is one of the storage accounts that is available via the ``list_storage``
  658. function.
  659. storage_key
  660. ~~~~~~~~~~~
  661. Both a primary and a secondary ``storage_key`` can be obtained by running the
  662. ``show_storage_keys`` function. Either key may be used.
  663. Blob Functions
  664. --------------
  665. The following functions are made available through Salt Cloud for managing
  666. blog storage.
  667. make_blob_url
  668. ~~~~~~~~~~~~~
  669. Creates the URL to access a blob
  670. .. code-block:: bash
  671. salt-cloud -f make_blob_url my-azure container=mycontainer blob=myblob
  672. container
  673. `````````
  674. Name of the container.
  675. blob
  676. ````
  677. Name of the blob.
  678. account
  679. ```````
  680. Name of the storage account. If not specified, derives the host base
  681. from the provider configuration.
  682. protocol
  683. ````````
  684. Protocol to use: 'http' or 'https'. If not specified, derives the host
  685. base from the provider configuration.
  686. host_base
  687. `````````
  688. Live host base URL. If not specified, derives the host base from the
  689. provider configuration.
  690. list_storage_containers
  691. ~~~~~~~~~~~~~~~~~~~~~~~
  692. List containers associated with the storage account
  693. .. code-block:: bash
  694. salt-cloud -f list_storage_containers my-azure
  695. create_storage_container
  696. ~~~~~~~~~~~~~~~~~~~~~~~~
  697. Create a storage container
  698. .. code-block:: bash
  699. salt-cloud -f create_storage_container my-azure name=mycontainer
  700. name
  701. ````
  702. Name of container to create.
  703. meta_name_values
  704. ````````````````
  705. Optional. A dict with name_value pairs to associate with the
  706. container as metadata. Example:{'Category':'test'}
  707. blob_public_access
  708. ``````````````````
  709. Optional. Possible values include: container, blob
  710. fail_on_exist
  711. `````````````
  712. Specify whether to throw an exception when the container exists.
  713. show_storage_container
  714. ~~~~~~~~~~~~~~~~~~~~~~
  715. Show a container associated with the storage account
  716. .. code-block:: bash
  717. salt-cloud -f show_storage_container my-azure name=myservice
  718. name
  719. ````
  720. Name of container to show.
  721. show_storage_container_metadata
  722. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  723. Show a storage container's metadata
  724. .. code-block:: bash
  725. salt-cloud -f show_storage_container_metadata my-azure name=myservice
  726. name
  727. ````
  728. Name of container to show.
  729. lease_id
  730. ````````
  731. If specified, show_storage_container_metadata only succeeds if the
  732. container's lease is active and matches this ID.
  733. set_storage_container_metadata
  734. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  735. Set a storage container's metadata
  736. .. code-block:: bash
  737. salt-cloud -f set_storage_container my-azure name=mycontainer \
  738. x_ms_meta_name_values='{"my_name": "my_value"}'
  739. name
  740. ````
  741. Name of existing container.
  742. meta_name_values
  743. ````````````````
  744. A dict containing name, value for metadata.
  745. Example: {'category':'test'}
  746. lease_id
  747. ````````
  748. If specified, set_storage_container_metadata only succeeds if the
  749. container's lease is active and matches this ID.
  750. show_storage_container_acl
  751. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  752. Show a storage container's acl
  753. .. code-block:: bash
  754. salt-cloud -f show_storage_container_acl my-azure name=myservice
  755. name
  756. ````
  757. Name of existing container.
  758. lease_id
  759. ````````
  760. If specified, show_storage_container_acl only succeeds if the
  761. container's lease is active and matches this ID.
  762. set_storage_container_acl
  763. ~~~~~~~~~~~~~~~~~~~~~~~~~
  764. Set a storage container's acl
  765. .. code-block:: bash
  766. salt-cloud -f set_storage_container my-azure name=mycontainer
  767. name
  768. ````
  769. Name of existing container.
  770. signed_identifiers
  771. ``````````````````
  772. SignedIdentifers instance
  773. blob_public_access
  774. ``````````````````
  775. Optional. Possible values include: container, blob
  776. lease_id
  777. ````````
  778. If specified, set_storage_container_acl only succeeds if the
  779. container's lease is active and matches this ID.
  780. delete_storage_container
  781. ~~~~~~~~~~~~~~~~~~~~~~~~
  782. Delete a container associated with the storage account
  783. .. code-block:: bash
  784. salt-cloud -f delete_storage_container my-azure name=mycontainer
  785. name
  786. ````
  787. Name of container to create.
  788. fail_not_exist
  789. ``````````````
  790. Specify whether to throw an exception when the container exists.
  791. lease_id
  792. ````````
  793. If specified, delete_storage_container only succeeds if the
  794. container's lease is active and matches this ID.
  795. lease_storage_container
  796. ~~~~~~~~~~~~~~~~~~~~~~~
  797. Lease a container associated with the storage account
  798. .. code-block:: bash
  799. salt-cloud -f lease_storage_container my-azure name=mycontainer
  800. name
  801. ````
  802. Name of container to create.
  803. lease_action
  804. ````````````
  805. Required. Possible values: acquire|renew|release|break|change
  806. lease_id
  807. ````````
  808. Required if the container has an active lease.
  809. lease_duration
  810. ``````````````
  811. Specifies the duration of the lease, in seconds, or negative one
  812. (-1) for a lease that never expires. A non-infinite lease can be
  813. between 15 and 60 seconds. A lease duration cannot be changed
  814. using renew or change. For backwards compatibility, the default is
  815. 60, and the value is only used on an acquire operation.
  816. lease_break_period
  817. ``````````````````
  818. Optional. For a break operation, this is the proposed duration of
  819. seconds that the lease should continue before it is broken, between
  820. 0 and 60 seconds. This break period is only used if it is shorter
  821. than the time remaining on the lease. If longer, the time remaining
  822. on the lease is used. A new lease will not be available before the
  823. break period has expired, but the lease may be held for longer than
  824. the break period. If this header does not appear with a break
  825. operation, a fixed-duration lease breaks after the remaining lease
  826. period elapses, and an infinite lease breaks immediately.
  827. proposed_lease_id
  828. `````````````````
  829. Optional for acquire, required for change. Proposed lease ID, in a
  830. GUID string format.
  831. list_blobs
  832. ~~~~~~~~~~
  833. List blobs associated with the container
  834. .. code-block:: bash
  835. salt-cloud -f list_blobs my-azure container=mycontainer
  836. container
  837. `````````
  838. The name of the storage container
  839. prefix
  840. ``````
  841. Optional. Filters the results to return only blobs whose names
  842. begin with the specified prefix.
  843. marker
  844. ``````
  845. Optional. A string value that identifies the portion of the list
  846. to be returned with the next list operation. The operation returns
  847. a marker value within the response body if the list returned was
  848. not complete. The marker value may then be used in a subsequent
  849. call to request the next set of list items. The marker value is
  850. opaque to the client.
  851. maxresults
  852. ``````````
  853. Optional. Specifies the maximum number of blobs to return,
  854. including all BlobPrefix elements. If the request does not specify
  855. maxresults or specifies a value greater than 5,000, the server will
  856. return up to 5,000 items. Setting maxresults to a value less than
  857. or equal to zero results in error response code 400 (Bad Request).
  858. include
  859. ```````
  860. Optional. Specifies one or more datasets to include in the
  861. response. To specify more than one of these options on the URI,
  862. you must separate each option with a comma. Valid values are::
  863. snapshots:
  864. Specifies that snapshots should be included in the
  865. enumeration. Snapshots are listed from oldest to newest in
  866. the response.
  867. metadata:
  868. Specifies that blob metadata be returned in the response.
  869. uncommittedblobs:
  870. Specifies that blobs for which blocks have been uploaded,
  871. but which have not been committed using Put Block List
  872. (REST API), be included in the response.
  873. copy:
  874. Version 2012-02-12 and newer. Specifies that metadata
  875. related to any current or previous Copy Blob operation
  876. should be included in the response.
  877. delimiter
  878. `````````
  879. Optional. When the request includes this parameter, the operation
  880. returns a BlobPrefix element in the response body that acts as a
  881. placeholder for all blobs whose names begin with the same
  882. substring up to the appearance of the delimiter character. The
  883. delimiter may be a single character or a string.
  884. show_blob_service_properties
  885. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  886. Show a blob's service properties
  887. .. code-block:: bash
  888. salt-cloud -f show_blob_service_properties my-azure
  889. set_blob_service_properties
  890. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  891. Sets the properties of a storage account's Blob service, including
  892. Windows Azure Storage Analytics. You can also use this operation to
  893. set the default request version for all incoming requests that do not
  894. have a version specified.
  895. .. code-block:: bash
  896. salt-cloud -f set_blob_service_properties my-azure
  897. properties
  898. ``````````
  899. a StorageServiceProperties object.
  900. timeout
  901. ```````
  902. Optional. The timeout parameter is expressed in seconds.
  903. show_blob_properties
  904. ~~~~~~~~~~~~~~~~~~~~
  905. Returns all user-defined metadata, standard HTTP properties, and
  906. system properties for the blob.
  907. .. code-block:: bash
  908. salt-cloud -f show_blob_properties my-azure container=mycontainer blob=myblob
  909. container
  910. `````````
  911. Name of existing container.
  912. blob
  913. ````
  914. Name of existing blob.
  915. lease_id
  916. ````````
  917. Required if the blob has an active lease.
  918. set_blob_properties
  919. ~~~~~~~~~~~~~~~~~~~
  920. Set a blob's properties
  921. .. code-block:: bash
  922. salt-cloud -f set_blob_properties my-azure
  923. container
  924. `````````
  925. Name of existing container.
  926. blob
  927. ````
  928. Name of existing blob.
  929. blob_cache_control
  930. ``````````````````
  931. Optional. Modifies the cache control string for the blob.
  932. blob_content_type
  933. `````````````````
  934. Optional. Sets the blob's content type.
  935. blob_content_md5
  936. ````````````````
  937. Optional. Sets the blob's MD5 hash.
  938. blob_content_encoding
  939. `````````````````````
  940. Optional. Sets the blob's content encoding.
  941. blob_content_language
  942. `````````````````````
  943. Optional. Sets the blob's content language.
  944. lease_id
  945. ````````
  946. Required if the blob has an active lease.
  947. blob_content_disposition
  948. ````````````````````````
  949. Optional. Sets the blob's Content-Disposition header.
  950. The Content-Disposition response header field conveys additional
  951. information about how to process the response payload, and also can
  952. be used to attach additional metadata. For example, if set to
  953. attachment, it indicates that the user-agent should not display the
  954. response, but instead show a Save As dialog with a filename other
  955. than the blob name specified.
  956. put_blob
  957. ~~~~~~~~
  958. Upload a blob
  959. .. code-block:: bash
  960. salt-cloud -f put_blob my-azure container=base name=top.sls blob_path=/srv/salt/top.sls
  961. salt-cloud -f put_blob my-azure container=base name=content.txt blob_content='Some content'
  962. container
  963. `````````
  964. Name of existing container.
  965. name
  966. ````
  967. Name of existing blob.
  968. blob_path
  969. `````````
  970. The path on the local machine of the file to upload as a blob. Either
  971. this or blob_content must be specified.
  972. blob_content
  973. ````````````
  974. The actual content to be uploaded as a blob. Either this or blob_path
  975. must me specified.
  976. cache_control
  977. `````````````
  978. Optional. The Blob service stores this value but does not use or
  979. modify it.
  980. content_language
  981. ````````````````
  982. Optional. Specifies the natural languages used by this resource.
  983. content_md5
  984. ```````````
  985. Optional. An MD5 hash of the blob content. This hash is used to
  986. verify the integrity of the blob during transport. When this header
  987. is specified, the storage service checks the hash that has arrived
  988. with the one that was sent. If the two hashes do not match, the
  989. operation will fail with error code 400 (Bad Request).
  990. blob_content_type
  991. `````````````````
  992. Optional. Set the blob's content type.
  993. blob_content_encoding
  994. `````````````````````
  995. Optional. Set the blob's content encoding.
  996. blob_content_language
  997. `````````````````````
  998. Optional. Set the blob's content language.
  999. blob_content_md5
  1000. ````````````````
  1001. Optional. Set the blob's MD5 hash.
  1002. blob_cache_control
  1003. ``````````````````
  1004. Optional. Sets the blob's cache control.
  1005. meta_name_values
  1006. ````````````````
  1007. A dict containing name, value for metadata.
  1008. lease_id
  1009. ````````
  1010. Required if the blob has an active lease.
  1011. get_blob
  1012. ~~~~~~~~
  1013. Download a blob
  1014. .. code-block:: bash
  1015. salt-cloud -f get_blob my-azure container=base name=top.sls local_path=/srv/salt/top.sls
  1016. salt-cloud -f get_blob my-azure container=base name=content.txt return_content=True
  1017. container
  1018. `````````
  1019. Name of existing container.
  1020. name
  1021. ````
  1022. Name of existing blob.
  1023. local_path
  1024. ``````````
  1025. The path on the local machine to download the blob to. Either this or
  1026. return_content must be specified.
  1027. return_content
  1028. ``````````````
  1029. Whether or not to return the content directly from the blob. If
  1030. specified, must be True or False. Either this or the local_path must
  1031. be specified.
  1032. snapshot
  1033. ````````
  1034. Optional. The snapshot parameter is an opaque DateTime value that,
  1035. when present, specifies the blob snapshot to retrieve.
  1036. lease_id
  1037. ````````
  1038. Required if the blob has an active lease.
  1039. progress_callback
  1040. `````````````````
  1041. callback for progress with signature function(current, total) where
  1042. current is the number of bytes transferred so far, and total is the
  1043. size of the blob.
  1044. max_connections
  1045. ```````````````
  1046. Maximum number of parallel connections to use when the blob size
  1047. exceeds 64MB.
  1048. Set to 1 to download the blob chunks sequentially.
  1049. Set to 2 or more to download the blob chunks in parallel. This uses
  1050. more system resources but will download faster.
  1051. max_retries
  1052. ```````````
  1053. Number of times to retry download of blob chunk if an error occurs.
  1054. retry_wait
  1055. ``````````
  1056. Sleep time in secs between retries.