How to Use an Existing Public IP and Subnet for Ray Cluster on Azure?

Hi everyone,

I’m setting up a Ray cluster on Azure, and I want to use an existing subnet, virtual network, and public IP instead of letting Ray create new ones.

Here’s what I’ve done so far in my YAML configuration:

yaml

provider:
    type: azure
    location: Central India
    resource_group: BCS_Dev_RG
    subscription_id: <MY_SUBSCRIPTION_ID>

available_node_types:
    ray.head.default:
        node_config:
            azure_arm_parameters:
                vmName: ray-head-node  
                adminUsername: bcstest  
                publicKey: ~/.ssh/id_rsa.pub  
                imagePublisher: microsoft-dsvm  
                imageOffer: ubuntu-1804  
                imageSku: 1804-gen2  
                imageVersion: latest  
                vmSize: Standard_D2s_v3  
                provisionPublicIp: true  
                subnet: Ray_Sub01  # Using existing subnet

Issue:
Despite specifying provisionPublicIp: true and an existing subnet, Ray still creates a new public IP instead of attaching the existing one (e.g., ray_PubIP).

Questions:

  1. How can I ensure Ray uses an existing Public IP instead of creating a new one?
  2. Is there a way to explicitly define the virtual network and associate the head node with a pre-provisioned IP?
  3. Are there any limitations in Ray’s Azure provider that prevent attaching pre-existing network resources?

Any guidance would be really helpful! :rocket:

Thanks in advance! :blush:

there is no implementation to use your own vnet or subnet. it could definitely be added, but would require changes to the code and templates.
for now all you can do is provide address prefix information about your subnet if you wanted to adjust the CIDR ranges being used. Also that happens in the provider section, not in azure_arm_parameters.
So, i guess my suggestion would be to see if using vnet-peering is an option for you to connect the ray vnet to your existing vnet. Hope that helps.

1 Like

looking at the code, there does seem to be some logic to avoid over-writing existing resources based on the unique id that is created. so it seems possible that you could create a vnet with a specific id in the name, eg: vnet-1234, then you can specific the same id as your unique_id under the provider section of the yaml:

provider:
 unique_id: 1234

1 Like