<commit_before>---
title: Azure CPI
---

This topic describes cloud properties for different resources created by the Azure CPI.

## <a id='azs'></a> AZs

Currently the CPI does not support any cloud properties for AZs.

Example:

```yaml
azs:
- name: z1
```

---
## <a id="networks"></a> Networks

### Dynamic Network or Manual Network

Schema for `cloud_properties` section:

* **resource\_group\_name** [String, optional]: Name of a resource group. If it is set, Azure CPI will search the virtual network and security group in this resource group. Otherwise, Azure CPI will search the virtual network and security group in `resource_group_name` in the global CPI settings.
* **virtual\_network\_name** [String, required]: Name of a virtual network. Example: `boshnet`.
* **subnet_name** [String, required]: Name of a subnet within virtual network.
* **security_group** [String, optional]: The [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) to apply to network interfaces of all VMs placed in this network. The security group of a network interface can be specified either in a resource pool(higher priority) or a network configuration(lower priority); if it is not specified, the default security group (specified by `default_security_group` in the global CPI settings) will be used.

See [how to create a virtual network and subnets](azure-resources.html#virtual-network).

Example of manual network:

```yaml
networks:
- name: default
  type: manual
  subnets:
  - range: 10.10.0.0/24
    gateway: 10.10.0.1
    cloud_properties:
      resource_group_name: my-resource-group
      virtual_network_name: boshnet
      subnet_name: boshsub
```

### Vip Network

Schema for `cloud_properties` section:

* **resource\_group\_name** [String, optional]: Name of a resource group. If it is set, Azure CPI will search the public IP in this resource group. Otherwise, Azure CPI will search the public IP in `resource_group_name` in the global CPI settings.

See [how to create public IP](azure-resources.html#public-ips) to use with vip networks.

Example of vip network:

```yaml
networks:
- name: public
  type: vip
  cloud_properties:
    resource_group_name: my-resource-group
```

---
## <a id="resource-pools"></a> Resource Pools / VM Types

Schema for `cloud_properties` section:

* **instance_type** [String, required]: Type of the [instance](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/). Example: `Standard_A2`.
* **storage\_account\_name** [String, optional]: Storage account for VMs. If this is not set, the VMs will be created in the default storage account. See [this document](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/tree/master/docs/advanced/deploy-cloudfoundry-for-enterprise#multiple-storage-accounts) for more details on why this option exists.
    * If you use `DS-series` or `GS-series` as `instance_type`, you should set this to a premium storage account. See more information about [Azure premium storage](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage-preview-portal/). See [avaliable regions](http://azure.microsoft.com/en-us/regions/#services) where you can create premium storage accounts.
    * If you use a different storage account which must be in the same resource group, please make sure:
      1. The permissions for the container `stemcell` in the default storage account is set to `Public read access for blobs only`.
      1. A table `stemcells` is created in the default storage account.
      1. Two containers `bosh` and `stemcell` are created in the new storage account.
    * If this storage account does not exist, it can be created automatically by Azure CPI. But you must specify storage\_account\_type and make sure:
      1. The name must be **unique within Azure**.
      1. **The name must be between 3 and 24 characters in length and use numbers and lower-case letters only**.
    * If you use a pattern `*keyword*`. CPI will filter all storage accounts under the default resource group by the pattern and pick one available storage account to create the VM.
      1. The pattern must start with `*` and end with `*`.
      1. The keyword must only contain numbers and lower-case letters because of the naming rule of storage account name.
      1. The rule to select an available storage account is to check the number of disks under the container `bosh` does not exceed the limitation.
      1. The default number of disks limitation is 30 but you can specify it in **storage\_account\_max\_disk\_number**.
* **storage\_account\_max\_disk\_number** [Integer, optional]: Number of disks limitation in a storage account. Default value is 30. This will be used only when **storage\_account\_name** is a pattern.
    * Every storage account has a limitation to host disks. You may hit the performance issue if you create too many disks in one storage account.
    * The maximum number of disks of a standard storage account is 40 because the maximum IOPS of a standard storage account is 20,000 and the maximum IOPS of a standard disk is 500.
    * If you are using premium storage account, Azure maps the disk size (rounded up) to the nearest Premium Storage Disk option (P10, P20 and P30). For example, a disk of size 100 GiB is classified as a P10 option.
      1. The maximum number of disks of a premium storage account is 280 if you are using P10 (128 GiB) as your disk type.
      1. The maximum number of disks of a premium storage account is 70 if you are using P20 (512 GiB) as your disk type.
      1. The maximum number of disks of a premium storage account is 35 if you are using P30 (1024 GiB) as your disk type.
    * **storage\_account\_max\_disk\_number** should be less than the maximum number. Suggest you to use (MAX - 10) as the value because CPI always creates VMs in parallel.
    * Please see more information about [azure-subscription-service-limits](https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits/).
* **storage\_account\_type** [String, optional]: Storage account type. It is required if the storage account does not exist. It can be either `Standard_LRS`, `Standard_ZRS`, `Standard_GRS`, `Standard_RAGRS` or `Premium_LRS`. You can click [**HERE**](http://azure.microsoft.com/en-us/pricing/details/storage/) to learn more about the type of Azure storage account.
* **storage\_account\_location** [String, optional]: Location of the storage account. It is needed if the storage account does not exist. If it is not set, the location of the default resource group will be used. For more information, see [List all of the available geo-locations](http://azure.microsoft.com/en-us/regions/). For `AzureChinaCloud`, you should only use the regions in China, `chinanorth` or `chinaeast`.
* **availability_set** [String, optional]: Name of an [availability set](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) to use for VMs. [More details](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/tree/master/docs/advanced/deploy-cloudfoundry-for-enterprise#availability-set).
    * If available set does not exist, it will be automatically created.
    * If `availability_set` is not specified, Azure CPI will search `env.bosh.group_name` as the name of availability set. If neither `availability_set` nor `env.bosh.group_name` exists, VMs in this resource_pool won't be in any availability set.
* **platform\_update\_domain_count** [Integer, optional]: The count of [update domain](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) in the availability set. Default value is `5`.
* **platform\_fault\_domain_count** [Integer, optional]: The count of [fault domain](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) in the availability set. Default value is `3`.
* **load_balancer** [String, optional]: Name of an [load balancer](https://azure.microsoft.com/en-us/documentation/articles/load-balancer-overview/) the VMs should belong to. You need to create the load balancer manually before configuring it.
* **security_group** [String, optional]: The [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) to apply to network interfaces of all VMs placed in this resource pool. The security group of a network interface can be specified either in a resource pool(higher priority) or a network configuration(lower priority); if it is not specified, the default security group (specified by `default_security_group` in the global CPI settings) will be used.
* **caching** [String, optional]: Type of the disk caching of the VMs' OS disks. It can be either `None`, `ReadOnly` or `ReadWrite`. Default is `ReadWrite`.
* **root_disk** [Hash, optional]: OS disk of custom size.
    * **size** [Integer, optional]: Specifies the disk size in MiB.
      * The size must be in the range [3 * 1024, 1023 * 1024]. Please always use `N * 1024` as the size because Azure always uses GiB but not MiB.
      * It has a default value `30 * 1024` only when ephemeral_disk.use\_root\_disk is set to true.
* **ephemeral_disk** [Hash, optional]: Ephemeral disk to apply for all VMs that are in this resource pool. By default a data disk with the default size as below will be created as the ephemeral disk.
    * **use\_root\_disk** [Boolean, optional]: Enable to use OS disk to store the ephemeral data. The default value is false. When it is true, ephemeral_disk.size will not be used.
    * **size** [Integer, optional]: Specifies the disk size in MiB. If this is not set, the default size as below will be used. The size of the ephemeral disk for the BOSH VM should be larger than or equal to `30*1024` MiB. Please always use `N * 1024` as the size because Azure always uses GiB not MiB.
      * If the Azure temporary disk size for the instance type is less than `30*1024` MiB, the default size is `30*1024` MiB because the space may not be enough.
      * If the Azure temporary disk size for the instance type is larger than `1023*1024` MiB, the default size is `1023*1024` MiB because max data disk size is `1023*1024` MiB on Azure.
      * Otherwise, the Azure temporary disk size will be used as the default size. See more information about [Azure temporary disk size](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/).

Example of `env.bosh.group_name`:
* **env** [Hash, optional]:
    * **bosh** [Hash, optional]:
      * **group_name** [String, optional]: This will be used as the name of availability set for VMs when `cloud_properties.availability_set` does not exist.

Example of a `Standard_A2` instance:

```yaml
resource_pools:
- name: default
  network: default
  stemcell:
    name: bosh-azure-hyperv-ubuntu-trusty-go_agent
    version: latest
  cloud_properties:
    instance_type: Standard_A2
    availability_set: <availability-set-name>
    root_disk:
      size: 30_720
    ephemeral_disk:
      use_root_disk: false
      size: 30_720
  env:
    bosh:
      group_name: <availability-set-name>
```

---
## <a id="disk-pools"></a> Disk Pools / Disk Types

Schema for `cloud_properties` section:

* **caching** [String, optional]: Type of the disk caching. It can be either `None`, `ReadOnly` or `ReadWrite`. Default is `None`. Only `None` and `ReadOnly` are supported for premium disks.

Example of 10GB disk:

* **disk_size** [Integer, required]: Size of the disk in MiB. On Azure the disk size must be in the range [1 * 1024, 1023 * 1024]. Please always use `N * 1024` as the size because Azure always uses GiB not MiB.

```yaml
disk_pools:
- name: default
  disk_size: 10_240
```

---
## <a id="global"></a> Global Configuration

The CPI can only use single resource group.

Schema:

* **environment** [String, required]: Azure environment name. Possible values are: `AzureCloud`, `AzureChinaCloud` or `AzureStack`.
* **subscription_id** [String, required]: Subscription ID.
* **tenant_id** [String, required]: Tenant ID of the service principal.
* **client_id** [String, required]: Client ID of the service principal.
* **client_secret** [String, required]: Client secret of the service principal.
* **resource\_group\_name** [String, required]: Resource group name.
* **storage\_account\_name** [String, required]: Storage account name. It will be used as a default storage account for VM disks and stemcells.
* **ssh_user** [String, required]: SSH username. Default: `vcap`.
* **ssh\_public\_key** [String, required]: SSH public key.
* **default\_security\_group** [String, required]: Name of the default [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) that will be applied to all created VMs.
* **azure\_stack\_domain** [String, optional]: The domain for your AzureStack deployment.
* **azure\_stack\_authentication** [String, optional]: The authentication type for your AzureStack deployment. Possible values are: `AzureAD`, `AzureStackAD` or `AzureStack`.
* **parallel\_upload\_thread\_num** [Integer, optional]: The number of threads to upload stemcells in parallel. The default value is 16.
* **debug_mode** [Boolean, optional]: Enable debug mode to log all raw HTTP requests/responses. The default value is false.

See [all configuration options](https://bosh.io/jobs/cpi?source=github.com/cloudfoundry-incubator/bosh-azure-cpi-release).

See [Creating Azure resources](azure-resources.html) page for more details on how to create and configure above resources.

Example with hard-coded credentials:

```yaml
properties:
  azure: &azure
    environment: AzureCloud
    subscription_id: 3c39a033-c306-4615-a4cb-260418d63879
    tenant_id: 0412d4fa-43d2-414b-b392-25d5ca46561da
    client_id: 33e56099-0bde-8z93-a005-89c0f6df7465
    client_secret: client-secret
    resource_group_name: bosh-res-group
    storage_account_name: boshstore
    ssh_user: vcap
    ssh_public_key: "ssh-rsa <KEY>"
    default_security_group: nsg-azure
```

---
## <a id='cloud-config'></a> Example Cloud Config

```yaml
azs:
- name: z1
- name: z2

vm_types:
- name: default
  cloud_properties:
    instance_type: Standard_A2

disk_types:
- name: default
  disk_size: 10_240

networks:
- name: default
  type: manual
  subnets:
  - range: 10.10.0.0/24
    gateway: 10.10.0.1
    dns: [192.168.3.11]
    azs: [z1, z2]
    cloud_properties:
      virtual_network_name: boshnet
      subnet_name: boshsub
- name: vip
  type: vip

compilation:
  workers: 5
  reuse_compilation_vms: true
  az: z1
  vm_type: default
  network: default
```

---
## <a id="errors"></a> Errors

* Invalid service principal

  ```
  http_get_response - get_token - http error: 400
  ```

  Service principal is most likely invalid. Verify that client ID, client secret and tenant ID successfully work:

  <pre class="terminal">
  $ azure login --username client-id --password client-secret --service-principal --tenant tenant-id
  </pre>

  If your service principal worked and you get the above error suddenly, it may be caused by that your service principal expired. You need to go to Azure Portal to update client secret. By default, the service principal will expire in one year.

  1. Go to [Azure Portal](https://manage.windowsazure.com/), select `active directory` -- > ORGANIZATION-NAME -- > `Applications` -- > search your service principal name.

  2. Then choose your service principal, select `Configure` -- > `keys` -- > add a new key.

* Exceeding quota limits of Core

  ```
  http_put - error: 409 message: {
    "error": {
      "code": "OperationNotAllowed",
      "message": "Operation results in exceeding quota limits of Core. Maximum allowed: 4, Current in use: 4, Additional requested: 1."
    }
  }
  ```

  Either upgrade your trial account, or file a support ticket in the Azure portal to raise account quotas.

* NicInUse

  ```
  http_delete - error: 400 message: {
      "error": {
          "code": "NicInUse",
          "message": "Network Interface /.../networkInterfaces/dc0d3a9a-0b00-40d8-830d-41e6f4ac9809 is used by existing VM /.../virtualMachines/dc0d3a9a-0b00-40d8-830d-41e6f4ac9809.",
          "details": []
      }
  }
  ```

  This error indicates that unknown VM (to the Director) took up the IP that the Director is trying to assign to a new VM. Either let the Director know to not use this IP by including it in the reserved section of a subnet in your manual network, or make that IP available by terminating the unknown VM.

* Limits of Premium Storage blob snapshots

  ```
  Error 100: Unknown CPI error 'Unknown' with message 'SnaphotOperationRateExceeded (409): The rate of snapshot blob calls is exceeded.
  ```

  The BOSH snapshot operation may be throttled if you do all of the following:

  * Use Premium Storage for the Cloud Foundry VMs.

  * Enable snapshot in `bosh.yml`. For more information on BOSH Snapshots, please go to https://bosh.io/docs/snapshots.html.

    ```
    director:
      enable_snapshots: true
    ```

  * The time between consecutive snapshots by BOSH is less than **10 minutes**. The limits are documented in [Snapshots and Copy Blob for Premium Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage/#snapshots-and-copy-blob).

  The workaround is:

  * Disable snapshot temporarily.

    ```
    director:
      enable_snapshots: false
    ```

  * Adjust the snapshot interval to more than 10 minutes.

* Version mismatch between CPI and Stemcell

  For CPI v11 or later, the compatible stemcell version is v3181 or later. If the stemcell version is older than v3181, you may hit the following failure when deploying BOSH.

  ```
  Performing POST request:
    Post https://mbus-user:mbus-password@10.0.0.4:6868/agent: dial tcp 10.0.0.4:6868: getsockopt: connection refused
  ```

  It is recommended to use the latest version. For example, Stemcell v3232.5 or later, and CPI v12 or later. You may hit the issue [#135](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/issues/135) if you still use an older stemcell than v3232.5.

---
[Back to Table of Contents](index.html#cpi-config)
<commit_msg>Azure: Change env.bosh.group_name to env.bosh.group<commit_after>---
title: Azure CPI
---

This topic describes cloud properties for different resources created by the Azure CPI.

## <a id='azs'></a> AZs

Currently the CPI does not support any cloud properties for AZs.

Example:

```yaml
azs:
- name: z1
```

---
## <a id="networks"></a> Networks

### Dynamic Network or Manual Network

Schema for `cloud_properties` section:

* **resource\_group\_name** [String, optional]: Name of a resource group. If it is set, Azure CPI will search the virtual network and security group in this resource group. Otherwise, Azure CPI will search the virtual network and security group in `resource_group_name` in the global CPI settings.
* **virtual\_network\_name** [String, required]: Name of a virtual network. Example: `boshnet`.
* **subnet_name** [String, required]: Name of a subnet within virtual network.
* **security_group** [String, optional]: The [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) to apply to network interfaces of all VMs placed in this network. The security group of a network interface can be specified either in a resource pool(higher priority) or a network configuration(lower priority); if it is not specified, the default security group (specified by `default_security_group` in the global CPI settings) will be used.

See [how to create a virtual network and subnets](azure-resources.html#virtual-network).

Example of manual network:

```yaml
networks:
- name: default
  type: manual
  subnets:
  - range: 10.10.0.0/24
    gateway: 10.10.0.1
    cloud_properties:
      resource_group_name: my-resource-group
      virtual_network_name: boshnet
      subnet_name: boshsub
```

### Vip Network

Schema for `cloud_properties` section:

* **resource\_group\_name** [String, optional]: Name of a resource group. If it is set, Azure CPI will search the public IP in this resource group. Otherwise, Azure CPI will search the public IP in `resource_group_name` in the global CPI settings.

See [how to create public IP](azure-resources.html#public-ips) to use with vip networks.

Example of vip network:

```yaml
networks:
- name: public
  type: vip
  cloud_properties:
    resource_group_name: my-resource-group
```

---
## <a id="resource-pools"></a> Resource Pools / VM Types

Schema for `cloud_properties` section:

* **instance_type** [String, required]: Type of the [instance](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/). Example: `Standard_A2`.
* **storage\_account\_name** [String, optional]: Storage account for VMs. If this is not set, the VMs will be created in the default storage account. See [this document](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/tree/master/docs/advanced/deploy-cloudfoundry-for-enterprise#multiple-storage-accounts) for more details on why this option exists.
    * If you use `DS-series` or `GS-series` as `instance_type`, you should set this to a premium storage account. See more information about [Azure premium storage](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage-preview-portal/). See [avaliable regions](http://azure.microsoft.com/en-us/regions/#services) where you can create premium storage accounts.
    * If you use a different storage account which must be in the same resource group, please make sure:
      1. The permissions for the container `stemcell` in the default storage account is set to `Public read access for blobs only`.
      1. A table `stemcells` is created in the default storage account.
      1. Two containers `bosh` and `stemcell` are created in the new storage account.
    * If this storage account does not exist, it can be created automatically by Azure CPI. But you must specify storage\_account\_type and make sure:
      1. The name must be **unique within Azure**.
      1. **The name must be between 3 and 24 characters in length and use numbers and lower-case letters only**.
    * If you use a pattern `*keyword*`. CPI will filter all storage accounts under the default resource group by the pattern and pick one available storage account to create the VM.
      1. The pattern must start with `*` and end with `*`.
      1. The keyword must only contain numbers and lower-case letters because of the naming rule of storage account name.
      1. The rule to select an available storage account is to check the number of disks under the container `bosh` does not exceed the limitation.
      1. The default number of disks limitation is 30 but you can specify it in **storage\_account\_max\_disk\_number**.
* **storage\_account\_max\_disk\_number** [Integer, optional]: Number of disks limitation in a storage account. Default value is 30. This will be used only when **storage\_account\_name** is a pattern.
    * Every storage account has a limitation to host disks. You may hit the performance issue if you create too many disks in one storage account.
    * The maximum number of disks of a standard storage account is 40 because the maximum IOPS of a standard storage account is 20,000 and the maximum IOPS of a standard disk is 500.
    * If you are using premium storage account, Azure maps the disk size (rounded up) to the nearest Premium Storage Disk option (P10, P20 and P30). For example, a disk of size 100 GiB is classified as a P10 option.
      1. The maximum number of disks of a premium storage account is 280 if you are using P10 (128 GiB) as your disk type.
      1. The maximum number of disks of a premium storage account is 70 if you are using P20 (512 GiB) as your disk type.
      1. The maximum number of disks of a premium storage account is 35 if you are using P30 (1024 GiB) as your disk type.
    * **storage\_account\_max\_disk\_number** should be less than the maximum number. Suggest you to use (MAX - 10) as the value because CPI always creates VMs in parallel.
    * Please see more information about [azure-subscription-service-limits](https://azure.microsoft.com/en-us/documentation/articles/azure-subscription-service-limits/).
* **storage\_account\_type** [String, optional]: Storage account type. It is required if the storage account does not exist. It can be either `Standard_LRS`, `Standard_ZRS`, `Standard_GRS`, `Standard_RAGRS` or `Premium_LRS`. You can click [**HERE**](http://azure.microsoft.com/en-us/pricing/details/storage/) to learn more about the type of Azure storage account.
* **storage\_account\_location** [String, optional]: Location of the storage account. It is needed if the storage account does not exist. If it is not set, the location of the default resource group will be used. For more information, see [List all of the available geo-locations](http://azure.microsoft.com/en-us/regions/). For `AzureChinaCloud`, you should only use the regions in China, `chinanorth` or `chinaeast`.
* **availability_set** [String, optional]: Name of an [availability set](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) to use for VMs. [More details](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/tree/master/docs/advanced/deploy-cloudfoundry-for-enterprise#availability-set).
    * If available set does not exist, it will be automatically created.
    * If `availability_set` is not specified, Azure CPI will search `env.bosh.group` as the name of availability set. If neither `availability_set` nor `env.bosh.group` exists, VMs in this resource_pool won't be in any availability set.
* **platform\_update\_domain_count** [Integer, optional]: The count of [update domain](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) in the availability set. Default value is `5`.
* **platform\_fault\_domain_count** [Integer, optional]: The count of [fault domain](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-manage-availability/) in the availability set. Default value is `3`.
* **load_balancer** [String, optional]: Name of an [load balancer](https://azure.microsoft.com/en-us/documentation/articles/load-balancer-overview/) the VMs should belong to. You need to create the load balancer manually before configuring it.
* **security_group** [String, optional]: The [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) to apply to network interfaces of all VMs placed in this resource pool. The security group of a network interface can be specified either in a resource pool(higher priority) or a network configuration(lower priority); if it is not specified, the default security group (specified by `default_security_group` in the global CPI settings) will be used.
* **caching** [String, optional]: Type of the disk caching of the VMs' OS disks. It can be either `None`, `ReadOnly` or `ReadWrite`. Default is `ReadWrite`.
* **root_disk** [Hash, optional]: OS disk of custom size.
    * **size** [Integer, optional]: Specifies the disk size in MiB.
      * The size must be in the range [3 * 1024, 1023 * 1024]. Please always use `N * 1024` as the size because Azure always uses GiB but not MiB.
      * It has a default value `30 * 1024` only when ephemeral_disk.use\_root\_disk is set to true.
* **ephemeral_disk** [Hash, optional]: Ephemeral disk to apply for all VMs that are in this resource pool. By default a data disk with the default size as below will be created as the ephemeral disk.
    * **use\_root\_disk** [Boolean, optional]: Enable to use OS disk to store the ephemeral data. The default value is false. When it is true, ephemeral_disk.size will not be used.
    * **size** [Integer, optional]: Specifies the disk size in MiB. If this is not set, the default size as below will be used. The size of the ephemeral disk for the BOSH VM should be larger than or equal to `30*1024` MiB. Please always use `N * 1024` as the size because Azure always uses GiB not MiB.
      * If the Azure temporary disk size for the instance type is less than `30*1024` MiB, the default size is `30*1024` MiB because the space may not be enough.
      * If the Azure temporary disk size for the instance type is larger than `1023*1024` MiB, the default size is `1023*1024` MiB because max data disk size is `1023*1024` MiB on Azure.
      * Otherwise, the Azure temporary disk size will be used as the default size. See more information about [Azure temporary disk size](https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-linux-sizes/).

Example of `env.bosh.group`:
* **env** [Hash, optional]:
    * **bosh** [Hash, optional]:
      * **group** [String, optional]: This will be used as the name of availability set for VMs when `cloud_properties.availability_set` does not exist. On Azure the length of the availability set name must be between 1 and 80 characters. The group name which is generated by BOSH director may be too long. CPI will truncate the name to the following format `az-MD5-[LAST-40-CHARACTERS-OF-GROUP]` if the length is greater than 80.

Example of a `Standard_A2` instance:

```yaml
resource_pools:
- name: default
  network: default
  stemcell:
    name: bosh-azure-hyperv-ubuntu-trusty-go_agent
    version: latest
  cloud_properties:
    instance_type: Standard_A2
    availability_set: <availability-set-name>
    root_disk:
      size: 30_720
    ephemeral_disk:
      use_root_disk: false
      size: 30_720
  env:
    bosh:
      group: <availability-set-name>
```

---
## <a id="disk-pools"></a> Disk Pools / Disk Types

Schema for `cloud_properties` section:

* **caching** [String, optional]: Type of the disk caching. It can be either `None`, `ReadOnly` or `ReadWrite`. Default is `None`. Only `None` and `ReadOnly` are supported for premium disks.

Example of 10GB disk:

* **disk_size** [Integer, required]: Size of the disk in MiB. On Azure the disk size must be in the range [1 * 1024, 1023 * 1024]. Please always use `N * 1024` as the size because Azure always uses GiB not MiB.

```yaml
disk_pools:
- name: default
  disk_size: 10_240
```

---
## <a id="global"></a> Global Configuration

The CPI can only use single resource group.

Schema:

* **environment** [String, required]: Azure environment name. Possible values are: `AzureCloud`, `AzureChinaCloud` or `AzureStack`.
* **subscription_id** [String, required]: Subscription ID.
* **tenant_id** [String, required]: Tenant ID of the service principal.
* **client_id** [String, required]: Client ID of the service principal.
* **client_secret** [String, required]: Client secret of the service principal.
* **resource\_group\_name** [String, required]: Resource group name.
* **storage\_account\_name** [String, required]: Storage account name. It will be used as a default storage account for VM disks and stemcells.
* **ssh_user** [String, required]: SSH username. Default: `vcap`.
* **ssh\_public\_key** [String, required]: SSH public key.
* **default\_security\_group** [String, required]: Name of the default [security group](https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-nsg/) that will be applied to all created VMs.
* **azure\_stack\_domain** [String, optional]: The domain for your AzureStack deployment.
* **azure\_stack\_authentication** [String, optional]: The authentication type for your AzureStack deployment. Possible values are: `AzureAD`, `AzureStackAD` or `AzureStack`.
* **parallel\_upload\_thread\_num** [Integer, optional]: The number of threads to upload stemcells in parallel. The default value is 16.
* **debug_mode** [Boolean, optional]: Enable debug mode to log all raw HTTP requests/responses. The default value is false.

See [all configuration options](https://bosh.io/jobs/cpi?source=github.com/cloudfoundry-incubator/bosh-azure-cpi-release).

See [Creating Azure resources](azure-resources.html) page for more details on how to create and configure above resources.

Example with hard-coded credentials:

```yaml
properties:
  azure: &azure
    environment: AzureCloud
    subscription_id: 3c39a033-c306-4615-a4cb-260418d63879
    tenant_id: 0412d4fa-43d2-414b-b392-25d5ca46561da
    client_id: 33e56099-0bde-8z93-a005-89c0f6df7465
    client_secret: client-secret
    resource_group_name: bosh-res-group
    storage_account_name: boshstore
    ssh_user: vcap
    ssh_public_key: "ssh-rsa AAAAB3N...6HySEF6IkbJ"
    default_security_group: nsg-azure
```

---
## <a id='cloud-config'></a> Example Cloud Config

```yaml
azs:
- name: z1
- name: z2

vm_types:
- name: default
  cloud_properties:
    instance_type: Standard_A2

disk_types:
- name: default
  disk_size: 10_240

networks:
- name: default
  type: manual
  subnets:
  - range: 10.10.0.0/24
    gateway: 10.10.0.1
    dns: [192.168.3.11]
    azs: [z1, z2]
    cloud_properties:
      virtual_network_name: boshnet
      subnet_name: boshsub
- name: vip
  type: vip

compilation:
  workers: 5
  reuse_compilation_vms: true
  az: z1
  vm_type: default
  network: default
```

---
## <a id="errors"></a> Errors

* Invalid service principal

  ```
  http_get_response - get_token - http error: 400
  ```

  Service principal is most likely invalid. Verify that client ID, client secret and tenant ID successfully work:

  <pre class="terminal">
  $ azure login --username client-id --password client-secret --service-principal --tenant tenant-id
  </pre>

  If your service principal worked and you get the above error suddenly, it may be caused by that your service principal expired. You need to go to Azure Portal to update client secret. By default, the service principal will expire in one year.

  1. Go to [Azure Portal](https://manage.windowsazure.com/), select `active directory` -- > ORGANIZATION-NAME -- > `Applications` -- > search your service principal name.

  2. Then choose your service principal, select `Configure` -- > `keys` -- > add a new key.

* Exceeding quota limits of Core

  ```
  http_put - error: 409 message: {
    "error": {
      "code": "OperationNotAllowed",
      "message": "Operation results in exceeding quota limits of Core. Maximum allowed: 4, Current in use: 4, Additional requested: 1."
    }
  }
  ```

  Either upgrade your trial account, or file a support ticket in the Azure portal to raise account quotas.

* NicInUse

  ```
  http_delete - error: 400 message: {
      "error": {
          "code": "NicInUse",
          "message": "Network Interface /.../networkInterfaces/dc0d3a9a-0b00-40d8-830d-41e6f4ac9809 is used by existing VM /.../virtualMachines/dc0d3a9a-0b00-40d8-830d-41e6f4ac9809.",
          "details": []
      }
  }
  ```

  This error indicates that unknown VM (to the Director) took up the IP that the Director is trying to assign to a new VM. Either let the Director know to not use this IP by including it in the reserved section of a subnet in your manual network, or make that IP available by terminating the unknown VM.

* Limits of Premium Storage blob snapshots

  ```
  Error 100: Unknown CPI error 'Unknown' with message 'SnaphotOperationRateExceeded (409): The rate of snapshot blob calls is exceeded.
  ```

  The BOSH snapshot operation may be throttled if you do all of the following:

  * Use Premium Storage for the Cloud Foundry VMs.

  * Enable snapshot in `bosh.yml`. For more information on BOSH Snapshots, please go to https://bosh.io/docs/snapshots.html.

    ```
    director:
      enable_snapshots: true
    ```

  * The time between consecutive snapshots by BOSH is less than **10 minutes**. The limits are documented in [Snapshots and Copy Blob for Premium Storage](https://azure.microsoft.com/en-us/documentation/articles/storage-premium-storage/#snapshots-and-copy-blob).

  The workaround is:

  * Disable snapshot temporarily.

    ```
    director:
      enable_snapshots: false
    ```

  * Adjust the snapshot interval to more than 10 minutes.

* Version mismatch between CPI and Stemcell

  For CPI v11 or later, the compatible stemcell version is v3181 or later. If the stemcell version is older than v3181, you may hit the following failure when deploying BOSH.

  ```
  Performing POST request:
    Post https://mbus-user:mbus-password@10.0.0.4:6868/agent: dial tcp 10.0.0.4:6868: getsockopt: connection refused
  ```

  It is recommended to use the latest version. For example, Stemcell v3232.5 or later, and CPI v12 or later. You may hit the issue [#135](https://github.com/cloudfoundry-incubator/bosh-azure-cpi-release/issues/135) if you still use an older stemcell than v3232.5.

---
[Back to Table of Contents](index.html#cpi-config)

{'fraction_non_alphanumeric': 0.09804561145994727, 'fraction_numerical': 0.022262089211449076, 'mean_word_length': 4.037655757907709, 'pattern_counts': {'":': 14, '<': 40, '<?xml version=': 0, '>': 50, 'https://': 38, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 14, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7018679', 'n_tokens_mistral': 11214, 'n_tokens_neox': 10319, 'n_words': 4442}