Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add a private subnet to a vnet with route table #1183

Closed
ddietterich opened this issue Oct 11, 2016 · 5 comments
Closed

Unable to add a private subnet to a vnet with route table #1183

ddietterich opened this issue Oct 11, 2016 · 5 comments
Assignees
Milestone

Comments

@ddietterich
Copy link

Using azure-jave-sdk 1.0.0-beta3. I have this code:
vnet.update() .withSubnet(clusterSubnetName, subnetCidr) .withTags(tags) .apply();

This fails with the error:

java.lang.IllegalArgumentException: subnets.routeTable.location is required and cannot be null. at com.microsoft.rest.Validator.validate(Validator.java:105) at com.microsoft.azure.management.network.implementation.VirtualNetworksInner.createOrUpdateWithServiceResponseAsync(VirtualNetworksInner.java:472) at com.microsoft.azure.management.network.implementation.VirtualNetworksInner.createOrUpdateAsync(VirtualNetworksInner.java:440) at com.microsoft.azure.management.network.implementation.NetworkImpl.createInner(NetworkImpl.java:202) at com.microsoft.azure.management.resources.fluentcore.arm.models.implementation.GroupableParentResourceImpl.createResourceAsync(GroupableParentResourceImpl.java:53) at com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl.updateResourceAsync(CreatableUpdatableImpl.java:189) at com.microsoft.azure.management.resources.fluentcore.model.implementation.CreateUpdateTask.executeAsync(CreateUpdateTask.java:43) at com.microsoft.azure.TaskGroupBase.executeAsync(TaskGroupBase.java:79) at com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl.executeTaskGroupAsync(CreatableUpdatableImpl.java:196) at com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl.applyAsync(CreatableUpdatableImpl.java:157) at com.microsoft.azure.management.resources.fluentcore.model.implementation.CreatableUpdatableImpl.apply(CreatableUpdatableImpl.java:178)

Looking at the code, it does look like route table is needed, but I cannot find any way to specify it. Is it missing from the beta3 API or am I missing something?

@martinsawicki
Copy link

route tables are not exposed in the API in beta3 yet.

@ddietterich
Copy link
Author

The application I am working on has a vnet with a public and a private subnet and a route table. I need to bring up clusters and (after users are done with them) destroy them. Each cluster wants its own subnet. So I need to add and remove private subnets from the vnet.

I've been trying to figure a workaround for this. If I do this:
vnet.update().withSubnet("foo", "a.b.c.d/nn"); Subnet foonet = vnet.subnets().get("foo");
I can use Subnet.inner() to get SubnetInner. From that I can do a withRouteTable to fill in the route table.

BUT, the route table isn't used when I finally do:
vnet.apply()

I tried to use
Subnet.UpdateDefinitionStages.WithAttach<Network.Update> subnetDef = vnet.update().defineSubnet(subnetName).withAddressPrefix(subnetCidr);
So I could fill in the route table and then do a .attach(), but Subnet.Update doesn't expose the SubnetInner inside.

I'm hoping someone can help me see how I can hook in here and get the route table in at the right point in the process.

@martinsawicki martinsawicki self-assigned this Oct 14, 2016
@martinsawicki
Copy link

it looks like this is not really related to the new API -- the way the reference to the RouteTable in the Subnet is auto-generated from the swagger spec is somewhat flawed. SubnetInner#routeTable is expecting a RouteTableInner instance, but it should expect a Subresource since this is only a R/W reference to an existing top level resource, not the resource itself.
This will require a manual change in the auto-generated SubnetInner. It is not only necessary for the workaround, but the addition of route table support to the fluent API layer itself requires it, as we will run into the same problem trying to wrap that API.
So basically, the lack of route table support does not appear to be currently workaroundable even using the auto-generated API.
I would expect route table support to appear in the master branch in the next couple of weeks.

@martinsawicki martinsawicki added this to the 1.0.0-beta4 milestone Oct 14, 2016
@martinsawicki martinsawicki changed the title Unable to add a private subnet to a vnet Unable to add a private subnet to a vnet with route tablel Oct 14, 2016
@martinsawicki martinsawicki changed the title Unable to add a private subnet to a vnet with route tablel Unable to add a private subnet to a vnet with route table Oct 14, 2016
@martinsawicki
Copy link

this checkin: be977fa will enable the following short-term workaround to work for assigning route tables to subnets:

// network is of type Network and is an existing virtual network
Subnet subnet = network.subnets().get("subnetName");
// routeTableResourceId is the resource ID of an existing route table
subnet.inner().withRouteTable(new SubResource().withId(routeTableResourceId));
network.update().apply();

In a few weeks, route tables will be exposed properly via the new API and this workaround will not be needed.

@martinsawicki
Copy link

route tables are exposed in the upcoming beta4

sima-zhu pushed a commit to sima-zhu/azure-sdk-for-java that referenced this issue Mar 21, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants