# Ray Cluster on Azure - how to use a custom vnet/subnet?

**URL:** <https://discuss.ray.io/t/ray-cluster-on-azure-how-to-use-a-custom-vnet-subnet/9111>\
**Category:** Ray Clusters\
**Created:** [January 26, 2023, 6:01pm UTC](https://discuss.ray.io/t/ray-cluster-on-azure-how-to-use-a-custom-vnet-subnet/9111 "2023-01-26T18:01:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![reiinakano](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/reiinakano/32/3784_2.png) [@reiinakano](https://discuss.ray.io/u/reiinakano)\
**Post date:** [January 26, 2023, 6:01pm UTC](https://discuss.ray.io/t/ray-cluster-on-azure-how-to-use-a-custom-vnet-subnet/9111/1 "2023-01-26T18:01:42Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- High: It blocks me to complete my task.

Hello! I’m trying to set a Ray Cluster on Azure, and due to security requirements, I’d like to start all the VMs within a custom subnet that already exists.

I’ve found a really hacky way to do that. At the moment, I can go into `ray/autoscaler/_private/_azure/node_provider.py` and add a `template_params["subnet"] = "my_subnet"` in `_create_node()` right before the template is passed in.

Obviously, this is not an ideal solution. Curious if there’s a better way? Happy to make a PR if needed.

---

<div class="post-metadata">

**Author:** ![Alex](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/alex/32/341_2.png) [@Alex](https://discuss.ray.io/u/Alex)\
**Post date:** [January 26, 2023, 7:19pm UTC](https://discuss.ray.io/t/ray-cluster-on-azure-how-to-use-a-custom-vnet-subnet/9111/2 "2023-01-26T19:19:11Z")

</div>

Maybe @gramhagen knows the best way to do this?

---

<div class="post-metadata">

**Author:** ![gramhagen](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/gramhagen/32/1172_2.png) [@gramhagen](https://discuss.ray.io/u/gramhagen)\
**Post date:** [January 30, 2023, 4:08pm UTC](https://discuss.ray.io/t/ray-cluster-on-azure-how-to-use-a-custom-vnet-subnet/9111/3 "2023-01-30T16:08:01Z")

</div>

you could just create a vnet with private ips only then do a vnet peering to the pre-existing vnet. alternatively providing that information in the deployment configuration yaml and passing it to the necessary arm templates is an option. happy to review or provide any useful info if you want to go the second route and push a pr.
