New in version 2014.1.0.
Azure is a cloud service by Microsoft providing virtual machines, SQL services, media services, and more. This document describes how to use Salt Cloud to create a virtual machine on Azure, with Salt installed.
More information about Azure is located at http://www.windowsazure.com/.
Note
The Azure driver is currently being updated to work with the new version of the Python Azure SDK, 1.0.0. However until that process is complete, this driver will not work with Azure 1.0.0. Please be sure you're running on a minimum version of 0.10.2 and less than version 1.0.0.
See Issue #27980 for more information.
Set up the provider config at /etc/salt/cloud.providers.d/azure.conf
:
# Note: This example is for /etc/salt/cloud.providers.d/azure.conf
my-azure-config:
driver: azure
subscription_id: 3287abc8-f98a-c678-3bde-326766fd3617
certificate_path: /etc/salt/azure.pem
# Set up the location of the salt master
#
minion:
master: saltmaster.example.com
# Optional
management_host: management.core.windows.net
The certificate used must be generated by the user. OpenSSL can be used to create the management certificates. Two certificates are needed: a .cer file, which is uploaded to Azure, and a .pem file, which is stored locally.
To create the .pem file, execute the following command:
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout /etc/salt/azure.pem -out /etc/salt/azure.pem
To create the .cer file, execute the following command:
openssl x509 -inform pem -in /etc/salt/azure.pem -outform der -out /etc/salt/azure.cer
After creating these files, the .cer file will need to be uploaded to Azure via the "Upload a Management Certificate" action of the "Management Certificates" tab within the "Settings" section of the management portal.
Optionally, a management_host
may be configured, if necessary for the region.
Note
Changed in version 2015.8.0.
The provider
parameter in cloud provider definitions was renamed to driver
. This
change was made to avoid confusion with the provider
parameter that is used in cloud profile
definitions. Cloud provider definitions now use driver
to refer to the Salt cloud module that
provides the underlying functionality to connect to a cloud host, while cloud profiles continue
to use provider
to refer to provider configurations that you define.
Set up an initial profile at /etc/salt/cloud.profiles
:
azure-ubuntu:
provider: my-azure-config
image: 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20131003-en-us-30GB'
size: Small
location: 'East US'
ssh_username: azureuser
ssh_password: verybadpass
slot: production
media_link: 'http://portalvhdabcdefghijklmn.blob.core.windows.net/vhds'
virtual_network_name: azure-virtual-network
subnet_name: azure-subnet
These options are described in more detail below. Once configured, the profile can be realized with a salt command:
salt-cloud -p azure-ubuntu newinstance
This will create an salt minion instance named newinstance
in Azure. If
the command was executed on the salt-master, its Salt key will automatically
be signed on the master.
Once the instance has been created with salt-minion installed, connectivity to it can be verified with Salt:
salt newinstance test.ping
The following options are currently available for Azure.
The name of the provider as configured in /etc/salt/cloud.providers.d/azure.conf.
The name of the image to use to create a VM. Available images can be viewed using the following command:
salt-cloud --list-images my-azure-config
The name of the size to use to create a VM. Available sizes can be viewed using the following command:
salt-cloud --list-sizes my-azure-config
The name of the location to create a VM in. Available locations can be viewed using the following command:
salt-cloud --list-locations my-azure-config
The name of the affinity group to create a VM in. Either a location
or an
affinity_group
may be specified, but not both. See Affinity Groups below.
The user to use to log into the newly-created VM to install Salt.
The password to use to log into the newly-created VM to install Salt.
The environment to which the hosted service is deployed. Valid values are staging or production. When set to production, the resulting URL of the new VM will be <vm_name>.cloudapp.net. When set to staging, the resulting URL will contain a generated hash instead.
This is the URL of the container that will store the disk that this VM uses. Currently, this container must already exist. If a VM has previously been created in the associated account, a container should already exist. In the web interface, go into the Storage area and click one of the available storage selections. Click the Containers link, and then copy the URL from the container that will be used. It generally looks like:
http://portalvhdabcdefghijklmn.blob.core.windows.net/vhds
The name of the service in which to create the VM. If this is not specified, then a service will be created with the same name as the VM.
Optional. The name of the virtual network for the VM to join. If this is not specified, then no virtual network will be joined.
Optional. The name of the subnet in the virtual network for the VM to join.
Requires that a virtual_network_name
is specified.
This action is a thin wrapper around --full-query
, which displays details on
a single instance only. In an environment with several machines, this will save
a user from having to sort through all instance data, just to examine a single
instance.
salt-cloud -a show_instance myinstance
There are certain options which can be specified in the global cloud
configuration file (usually /etc/salt/cloud
) which affect Salt Cloud's
behavior when a VM is destroyed.
New in version 2015.8.0.
Default is False
. When set to True
, Salt Cloud will wait for the VM to
be destroyed, then attempt to destroy the main disk that is associated with the
VM.
New in version 2015.8.0.
Default is False
. Requires cleanup_disks
to be set to True
. When
also set to True
, Salt Cloud will ask Azure to delete the VHD associated
with the disk that is also destroyed.
New in version 2015.8.0.
Default is False
. Requires cleanup_disks
to be set to True
. When
also set to True
, Salt Cloud will wait for the disk to be destroyed, then
attempt to remove the service that is associated with the VM. Because the disk
belongs to the service, the disk must be destroyed before the service can be.
New in version 2015.8.0.
An account can have one or more hosted services. A hosted service is required in order to create a VM. However, as mentioned above, if a hosted service is not specified when a VM is created, then one will automatically be created with the name of the name. The following functions are also available.
Create a hosted service. The following options are available.
Required. The name of the hosted service to create.
Required. A label to apply to the hosted service.
Optional. A longer description of the hosted service.
Required, if affinity_group
is not set. The location in which to create the
hosted service. Either the location
or the affinity_group
must be set,
but not both.
Required, if location
is not set. The affinity group in which to create the
hosted service. Either the location
or the affinity_group
must be set,
but not both.
Optional. Dictionary containing name/value pairs of hosted service properties. You can have a maximum of 50 extended property name/value pairs. The maximum length of the Name element is 64 characters, only alphanumeric characters and underscores are valid in the Name, and the name must start with a letter. The value has a maximum length of 255 characters.
The following example illustrates creating a hosted service.
salt-cloud -f create_service my-azure name=my-service label=my-service location='West US'
Return details about a specific hosted service. Can also be called with
get_service
.
salt-cloud -f show_storage my-azure name=my-service
List all hosted services associates with the subscription.
salt-cloud -f list_services my-azure-config
Delete a specific hosted service.
salt-cloud -f delete_service my-azure name=my-service
New in version 2015.8.0.
Salt Cloud can manage storage accounts associated with the account. The following functions are available. Deprecated marked as deprecated are marked as such as per the SDK documentation, but are still included for completeness with the SDK.
Create a storage account. The following options are supported.
Required. The name of the storage account to create.
Required. A label to apply to the storage account.
Optional. A longer description of the storage account.
Required, if affinity_group
is not set. The location in which to create the
storage account. Either the location
or the affinity_group
must be set,
but not both.
Required, if location
is not set. The affinity group in which to create the
storage account. Either the location
or the affinity_group
must be set,
but not both.
Optional. Dictionary containing name/value pairs of storage account properties. You can have a maximum of 50 extended property name/value pairs. The maximum length of the Name element is 64 characters, only alphanumeric characters and underscores are valid in the Name, and the name must start with a letter. The value has a maximum length of 255 characters.
Deprecated. Replaced by the account_type parameter.
Specifies whether the account supports locally-redundant storage, geo-redundant storage, zone-redundant storage, or read access geo-redundant storage. Possible values are:
The following example illustrates creating a storage account.
salt-cloud -f create_storage my-azure name=my-storage label=my-storage location='West US'
List all storage accounts associates with the subscription.
salt-cloud -f list_storage my-azure-config
Return details about a specific storage account. Can also be called with
get_storage
.
salt-cloud -f show_storage my-azure name=my-storage
Update details concerning a storage account. Any of the options available in
create_storage
can be used, but the name cannot be changed.
salt-cloud -f update_storage my-azure name=my-storage label=my-storage
Delete a specific storage account.
salt-cloud -f delete_storage my-azure name=my-storage
Returns the primary and secondary access keys for the specified storage account.
salt-cloud -f show_storage_keys my-azure name=my-storage
Regenerate storage account keys. Requires a key_type ("primary" or "secondary") to be specified.
salt-cloud -f regenerate_storage_keys my-azure name=my-storage key_type=primary
New in version 2015.8.0.
When a VM is created, a disk will also be created for it. The following functions are available for managing disks. Deprecated marked as deprecated are marked as such as per the SDK documentation, but are still included for completeness with the SDK.
Return details about a specific disk. Can also be called with get_disk
.
salt-cloud -f show_disk my-azure name=my-disk
Update details for a disk. The following options are available.
Required. The name of the disk to update.
Deprecated.
Required. The label for the disk.
Deprecated. The location of the disk in the account, including the storage container that it is in. This should not need to be changed.
Deprecated. If renaming the disk, the new name.
Deprecated.
The following example illustrates updating a disk.
salt-cloud -f update_disk my-azure name=my-disk label=my-disk
New in version 2015.8.0.
Stored at the cloud service level, these certificates are used by your deployed services. For more information on service certificates, see the following link:
The following functions are available.
List service certificates associated with the account.
salt-cloud -f list_service_certificates my-azure
Show the data for a specific service certificate associated with the account.
The name
, thumbprint
, and thumbalgorithm
can be obtained from
list_service_certificates
. Can also be called with
get_service_certificate
.
salt-cloud -f show_service_certificate my-azure name=my_service_certificate \
thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
Add a service certificate to the account. This requires that a certificate already exists, which is then added to the account. For more information on creating the certificate itself, see:
The following options are available.
Required. The name of the hosted service that the certificate will belong to.
Required. The base-64 encoded form of the pfx file.
Required. The service certificate format. The only supported value is pfx.
The certificate password.
salt-cloud -f add_service_certificate my-azure name=my-cert \
data='...CERT_DATA...' certificate_format=pfx password=verybadpass
Delete a service certificate from the account. The name
, thumbprint
,
and thumbalgorithm
can be obtained from list_service_certificates
.
salt-cloud -f delete_service_certificate my-azure \
name=my_service_certificate \
thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
New in version 2015.8.0.
A Azure management certificate is an X.509 v3 certificate used to authenticate an agent, such as Visual Studio Tools for Windows Azure or a client application that uses the Service Management API, acting on behalf of the subscription owner to manage subscription resources. Azure management certificates are uploaded to Azure and stored at the subscription level. The management certificate store can hold up to 100 certificates per subscription. These certificates are used to authenticate your Windows Azure deployment.
For more information on management certificates, see the following link.
The following functions are available.
List management certificates associated with the account.
salt-cloud -f list_management_certificates my-azure
Show the data for a specific management certificate associated with the account.
The name
, thumbprint
, and thumbalgorithm
can be obtained from
list_management_certificates
. Can also be called with
get_management_certificate
.
salt-cloud -f show_management_certificate my-azure name=my_management_certificate \
thumbalgorithm=sha1 thumbprint=0123456789ABCDEF
Management certificates must have a key length of at least 2048 bits and should reside in the Personal certificate store. When the certificate is installed on the client, it should contain the private key of the certificate. To upload to the certificate to the Microsoft Azure Management Portal, you must export it as a .cer format file that does not contain the private key. For more information on creating management certificates, see the following link:
The following options are available.
A base64 representation of the management certificate public key.
The thumb print that uniquely identifies the management certificate.
The certificate's raw data in base-64 encoded .cer format.
salt-cloud -f add_management_certificate my-azure public_key='...PUBKEY...' \
thumbprint=0123456789ABCDEF data='...CERT_DATA...'
Delete a management certificate from the account. The thumbprint
can be
obtained from list_management_certificates
.
salt-cloud -f delete_management_certificate my-azure thumbprint=0123456789ABCDEF
New in version 2015.8.0.
The following are functions for managing virtual networks.
List input endpoints associated with the deployment.
salt-cloud -f list_virtual_networks my-azure service=myservice deployment=mydeployment
New in version 2015.8.0.
Input endpoints are used to manage port access for roles. Because endpoints
cannot be managed by the Azure Python SDK, Salt Cloud uses the API directly.
With versions of Python before 2.7.9, the requests-python
package needs to
be installed in order for this to work. Additionally, the following needs to be
set in the master's configuration file:
requests_lib: True
The following functions are available.
List input endpoints associated with the deployment
salt-cloud -f list_input_endpoints my-azure service=myservice deployment=mydeployment
Show an input endpoint associated with the deployment
salt-cloud -f show_input_endpoint my-azure service=myservice \
deployment=mydeployment name=SSH
Add an input endpoint to the deployment. Please note that there may be a delay before the changes show up. The following options are available.
Required. The name of the hosted service which the VM belongs to.
Required. The name of the deployment that the VM belongs to. If the VM was created with Salt Cloud, the deployment name probably matches the VM name.
Required. The name of the role that the VM belongs to. If the VM was created with Salt Cloud, the role name probably matches the VM name.
Required. The name of the input endpoint. This typically matches the port that the endpoint is set to. For instance, port 22 would be called SSH.
Required. The public (Internet-facing) port that is used for the endpoint.
Optional. The private port on the VM itself that will be matched with the port.
This is typically the same as the port
. If this value is not specified, it
will be copied from port
.
Required. Either tcp
or udp
.
Optional. If an internal load balancer exists in the account, it can be used
with a direct server return. The default value is False
. Please see the
following article for an explanation of this option.
Optional. The default value is 4
. Please see the following article for an
explanation of this option.
The following example illustrates adding an input endpoint.
salt-cloud -f add_input_endpoint my-azure service=myservice \
deployment=mydeployment role=myrole name=HTTP local_port=80 \
port=80 protocol=tcp enable_direct_server_return=False \
timeout_for_tcp_idle_connection=4
Updates the details for a specific input endpoint. All options from
add_input_endpoint
are supported.
salt-cloud -f update_input_endpoint my-azure service=myservice \
deployment=mydeployment role=myrole name=HTTP local_port=80 \
port=80 protocol=tcp enable_direct_server_return=False \
timeout_for_tcp_idle_connection=4
Delete an input endpoint from the deployment. Please note that there may be a delay before the changes show up. The following items are required.
The following example illustrates deleting an input endpoint.
The name of the hosted service which the VM belongs to.
The name of the deployment that the VM belongs to. If the VM was created with Salt Cloud, the deployment name probably matches the VM name.
The name of the role that the VM belongs to. If the VM was created with Salt Cloud, the role name probably matches the VM name.
The name of the input endpoint. This typically matches the port that the endpoint is set to. For instance, port 22 would be called SSH.
salt-cloud -f delete_input_endpoint my-azure service=myservice \
deployment=mydeployment role=myrole name=HTTP
New in version 2015.8.0.
Affinity groups allow you to group your Azure services to optimize performance. All services and VMs within an affinity group will be located in the same region. For more information on Affinity groups, see the following link:
The following functions are available.
List input endpoints associated with the account
salt-cloud -f list_affinity_groups my-azure
Show an affinity group associated with the account
salt-cloud -f show_affinity_group my-azure service=myservice \
deployment=mydeployment name=SSH
Create a new affinity group. The following options are supported.
Required. The name of the new affinity group.
Required. The region in which the affinity group lives.
Required. A label describing the new affinity group.
Optional. A longer description of the affinity group.
salt-cloud -f create_affinity_group my-azure name=my_affinity_group \
label=my-affinity-group location='West US'
Update an affinity group's properties
salt-cloud -f update_affinity_group my-azure name=my_group label=my_group
Delete a specific affinity group associated with the account
salt-cloud -f delete_affinity_group my-azure name=my_affinity_group
New in version 2015.8.0.
Azure storage containers and their contents can be managed with Salt Cloud. This is not as elegant as using one of the other available clients in Windows, but it benefits Linux and Unix users, as there are fewer options available on those platforms.
Blob storage must be configured differently than the standard Azure
configuration. Both a storage_account
and a storage_key
must be
specified either through the Azure provider configuration (in addition to the
other Azure configuration) or via the command line.
storage_account: mystorage
storage_key: ffhj334fDSGFEGDFGFDewr34fwfsFSDFwe==
This is one of the storage accounts that is available via the list_storage
function.
Both a primary and a secondary storage_key
can be obtained by running the
show_storage_keys
function. Either key may be used.
The following functions are made available through Salt Cloud for managing blog storage.
Creates the URL to access a blob
salt-cloud -f make_blob_url my-azure container=mycontainer blob=myblob
Name of the container.
Name of the blob.
Name of the storage account. If not specified, derives the host base from the provider configuration.
Protocol to use: 'http' or 'https'. If not specified, derives the host base from the provider configuration.
Live host base URL. If not specified, derives the host base from the provider configuration.
List containers associated with the storage account
salt-cloud -f list_storage_containers my-azure
Create a storage container
salt-cloud -f create_storage_container my-azure name=mycontainer
Name of container to create.
Optional. A dict with name_value pairs to associate with the container as metadata. Example:{'Category':'test'}
Optional. Possible values include: container, blob
Specify whether to throw an exception when the container exists.
Show a container associated with the storage account
salt-cloud -f show_storage_container my-azure name=myservice
Name of container to show.
Show a storage container's metadata
salt-cloud -f show_storage_container_metadata my-azure name=myservice
Name of container to show.
If specified, show_storage_container_metadata only succeeds if the container's lease is active and matches this ID.
Set a storage container's metadata
salt-cloud -f set_storage_container my-azure name=mycontainer \
x_ms_meta_name_values='{"my_name": "my_value"}'
Name of existing container.
meta_name_values
````````````
A dict containing name, value for metadata.
Example: {'category':'test'}
lease_id
````
If specified, set_storage_container_metadata only succeeds if the
container's lease is active and matches this ID.
Show a storage container's acl
salt-cloud -f show_storage_container_acl my-azure name=myservice
Name of existing container.
If specified, show_storage_container_acl only succeeds if the container's lease is active and matches this ID.
Set a storage container's acl
salt-cloud -f set_storage_container my-azure name=mycontainer
Name of existing container.
SignedIdentifers instance
Optional. Possible values include: container, blob
If specified, set_storage_container_acl only succeeds if the container's lease is active and matches this ID.
Delete a container associated with the storage account
salt-cloud -f delete_storage_container my-azure name=mycontainer
Name of container to create.
Specify whether to throw an exception when the container exists.
If specified, delete_storage_container only succeeds if the container's lease is active and matches this ID.
Lease a container associated with the storage account
salt-cloud -f lease_storage_container my-azure name=mycontainer
Name of container to create.
Required. Possible values: acquire|renew|release|break|change
Required if the container has an active lease.
Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite lease can be between 15 and 60 seconds. A lease duration cannot be changed using renew or change. For backwards compatibility, the default is 60, and the value is only used on an acquire operation.
Optional. For a break operation, this is the proposed duration of seconds that the lease should continue before it is broken, between 0 and 60 seconds. This break period is only used if it is shorter than the time remaining on the lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has expired, but the lease may be held for longer than the break period. If this header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, and an infinite lease breaks immediately.
Optional for acquire, required for change. Proposed lease ID, in a GUID string format.
List blobs associated with the container
salt-cloud -f list_blobs my-azure container=mycontainer
The name of the storage container
Optional. Filters the results to return only blobs whose names begin with the specified prefix.
Optional. A string value that identifies the portion of the list to be returned with the next list operation. The operation returns a marker value within the response body if the list returned was not complete. The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque to the client.
Optional. Specifies the maximum number of blobs to return, including all BlobPrefix elements. If the request does not specify maxresults or specifies a value greater than 5,000, the server will return up to 5,000 items. Setting maxresults to a value less than or equal to zero results in error response code 400 (Bad Request).
Optional. Specifies one or more datasets to include in the response. To specify more than one of these options on the URI, you must separate each option with a comma. Valid values are:
snapshots:
Specifies that snapshots should be included in the
enumeration. Snapshots are listed from oldest to newest in
the response.
metadata:
Specifies that blob metadata be returned in the response.
uncommittedblobs:
Specifies that blobs for which blocks have been uploaded,
but which have not been committed using Put Block List
(REST API), be included in the response.
copy:
Version 2012-02-12 and newer. Specifies that metadata
related to any current or previous Copy Blob operation
should be included in the response.
Optional. When the request includes this parameter, the operation returns a BlobPrefix element in the response body that acts as a placeholder for all blobs whose names begin with the same substring up to the appearance of the delimiter character. The delimiter may be a single character or a string.
Show a blob's service properties
salt-cloud -f show_blob_service_properties my-azure
Sets the properties of a storage account's Blob service, including Windows Azure Storage Analytics. You can also use this operation to set the default request version for all incoming requests that do not have a version specified.
salt-cloud -f set_blob_service_properties my-azure
a StorageServiceProperties object.
Optional. The timeout parameter is expressed in seconds.
Returns all user-defined metadata, standard HTTP properties, and system properties for the blob.
salt-cloud -f show_blob_properties my-azure container=mycontainer blob=myblob
Name of existing container.
Name of existing blob.
Required if the blob has an active lease.
Set a blob's properties
salt-cloud -f set_blob_properties my-azure
Name of existing container.
Name of existing blob.
Optional. Modifies the cache control string for the blob.
Optional. Sets the blob's content type.
Optional. Sets the blob's MD5 hash.
Optional. Sets the blob's content encoding.
Optional. Sets the blob's content language.
Required if the blob has an active lease.
Optional. Sets the blob's Content-Disposition header. The Content-Disposition response header field conveys additional information about how to process the response payload, and also can be used to attach additional metadata. For example, if set to attachment, it indicates that the user-agent should not display the response, but instead show a Save As dialog with a filename other than the blob name specified.
Upload a blob
salt-cloud -f put_blob my-azure container=base name=top.sls blob_path=/srv/salt/top.sls
salt-cloud -f put_blob my-azure container=base name=content.txt blob_content='Some content'
Name of existing container.
Name of existing blob.
The path on the local machine of the file to upload as a blob. Either this or blob_content must be specified.
The actual content to be uploaded as a blob. Either this or blob_path must me specified.
Optional. The Blob service stores this value but does not use or modify it.
Optional. Specifies the natural languages used by this resource.
Optional. An MD5 hash of the blob content. This hash is used to verify the integrity of the blob during transport. When this header is specified, the storage service checks the hash that has arrived with the one that was sent. If the two hashes do not match, the operation will fail with error code 400 (Bad Request).
Optional. Set the blob's content type.
Optional. Set the blob's content encoding.
Optional. Set the blob's content language.
Optional. Set the blob's MD5 hash.
Optional. Sets the blob's cache control.
A dict containing name, value for metadata.
Required if the blob has an active lease.
Download a blob
salt-cloud -f get_blob my-azure container=base name=top.sls local_path=/srv/salt/top.sls
salt-cloud -f get_blob my-azure container=base name=content.txt return_content=True
Name of existing container.
Name of existing blob.
The path on the local machine to download the blob to. Either this or return_content must be specified.
Whether or not to return the content directly from the blob. If specified, must be True or False. Either this or the local_path must be specified.
Optional. The snapshot parameter is an opaque DateTime value that, when present, specifies the blob snapshot to retrieve.
Required if the blob has an active lease.
callback for progress with signature function(current, total) where current is the number of bytes transferred so far, and total is the size of the blob.
Maximum number of parallel connections to use when the blob size exceeds 64MB. Set to 1 to download the blob chunks sequentially. Set to 2 or more to download the blob chunks in parallel. This uses more system resources but will download faster.
Number of times to retry download of blob chunk if an error occurs.
Sleep time in secs between retries.