I was trying to create a multi node pool in Azure Batch (User Subscription) using C#. I have assigned the RBAC role of "Virtual Machine Contributor" to the Vnet for "Microsoft Azure Batch" along with it's already existing Contributor role. While I was able to create it successfully without Virtual Network Configuration, as soon as I add the property it fails with a Bad Request Exception. This is the snippet of code which i am using.
pool.NetworkConfiguration = new NetworkConfiguration
{
DynamicVNetAssignmentScope = 0,
PublicIPAddressConfiguration = new PublicIPAddressConfiguration(IPAddressProvisioningType.NoPublicIPAddresses),
SubnetId = "/subscriptions/<subscriptionId>/resourceGroups/<ResrouceGroupName>/providers/Microsoft.Network/virtualNetworks/<vnetName>/subnets/<subnetName>",
};