0
votes

I need to setup automatic creation of networks on demand. Set-AzureVNetConfig is not useful as it requires me to get all networks, edit and pass the new configuration back to Azure using this method (so this is a update)

I see a hidden option to create a netowork in portal, and want to know whats the option in PowerShell? I need something similar (see image below) as described in azure.microsoft.com/en-us/documentation/articles/create-virtual-network/

Which uses a REST API in the back-end to manage.windowsazure.com/Network/CreateVirtualNetwork which only accepts JSON request containing the new network details to be created. Creating Network on Azure Portal Hidden REST API Call

1
Here is the snippet of browser call when using Azure Portal to create a network URL: manage.windowsazure.com/Network/CreateVirtualNetwork POST: {"subscriptionId":"88349849384932809","location":"East US","virtualNetwork":{"name":"customer-10-network","AddressSpace":["10.0.0.0/24"],"Subnets":[{"name":"Subnet-1","AddressPrefix":"10.0.0.0/24"}],"DnsServersRef":[],"Gateway":null},"isWideVNetEnabled":true}am5
For sake of others: Anyone automating virtual network creation - you can't run it parallel and all changes have to be sequential You have to modify existing network configuration to add another one, there is no option to just add a virtual network without modifying existing network configuration file.am5

1 Answers

0
votes

Dynamically creating and overall management of Virtual Networks is quite hacky.

First, this what you see is not a "hidden REST Call". What you see is the management portal call to its backend. Management portal is HTML5 / jQuery / knockout based. It does not call directly the Azure Management API.

Now the theory - what we call in portal a Virtual Network is actually a Virtual Network Site for the API. Check the Azure Virtual Network Configuration Schema. So, in order to "create a new Virtual Network", we actually create a "new VNet site" within our Virtual Network.

Note that Virtual Network Configuration is only one per subscription! All we do, is changing this configuration.

Having said the above, dynamically changing this configuration is doable, but with the following constraints:

  • You can only perform one change at a time
  • You have to wait for running operation to complete in order to do the next change

Then, in order to make the things, you have to work with the XML network configuration directly. The easiest would be with PowerShell. I have some scripts in the shelf, will update the answer later when I find them. In short, you have to work with following cmdlets:

Update

Yes, two different people, admin and co-admin of same subscription cannot create two different virtual networks on the portal at the same time for the same subscription. Because changing a Virtual network configuration requires exclusive access - all operations on the Virtual network are blocked until first operation finishes.

Second - about reverse engineering the Portal and calling a custom, unofficial, unsupported API - You don't want to base your production deployments on a non-documented, non-supported API. Do I have to enlist reasons? Pick up some from:

  • This API is not documented, you will not get any support, and may change in any point of time
  • Speaking about change, there is Preview Portal: http://portal.azure.com which will replace the current portal. Which probably uses another API
  • it is unclear how the portal API authenticate requests
  • you do not know when it changes
  • you do not have a documentation and have base your code on assumptions

You question is something like:

When I browse my mailbox in outlook.com I see some hidden REST requests to https://xxx.mail.live.com/ol/mail.fpp?cnmn=Microsoft.Msn.Hotmail.xx=0&a=yyy%3d%3d&au=1872538104324017787 Can I use this API to base my Office365 Plugin application.