0

I am trying to run the following command to remove an unused Network Security Group in Azure but the command keeps returning "subnets/default cannot be null or empty."??

let subnetParameters = {
            id: "/subscriptions/MysubscriptionId/resourceGroups/helloStorageResouceGrp/providers/Microsoft.Network/virtualNetworks/helloStorageResouceGrpvnet860/subnets/default",
            networkSecurityGroup: {                    
                id:'/subscriptions/MySubscription/resourceGroups/helloStorageResouceGrp/providers/Microsoft.Network/networkSecurityGroups/babNewMachineForEncryption-nsg',
                name: null
            }
        }
        let resourceGroupName = 'helloStorageResouceGrp';
        let virtualNetworkName = 'helloStorageResouceGrpvnet860';
        let subnetName = 'default';
        let removeSecurityGroup = await NetworkManagement.subnets.createOrUpdate(resourceGroupName, virtualNetworkName, subnetName, subnetParameters)
        console.log('removeSecurityGroup: ', JSON.stringify(removeSecurityGroup));
Kainat
  • 63
  • 1
  • 8
  • Welcome to stackoverflow.com. For any specific problem you are having please include a https://stackoverflow.com/help/minimal-reproducible-example. Please also read https://stackoverflow.com/help/how-to-ask and https://stackoverflow.com/help/dont-ask. Make sure that your questions are specific and not overly broad, see also https://stackoverflow.com/help/on-topic. Also, be sure to take the https://stackoverflow.com/tour (you get a badge!) – Daniel Björk Aug 19 '20 at 12:49

1 Answers1

0

try doing this instead:

let subnetParameters = {
     id: "/subscriptions/MysubscriptionId/resourceGroups/helloStorageResouceGrp/providers/Microsoft.Network/virtualNetworks/helloStorageResouceGrpvnet860/subnets/default",
     networkSecurityGroup: {}
}
4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • Giving error code: 'InvalidRequestFormat', message: 'Cannot parse the request.', after passing this parameters – Kainat Aug 19 '20 at 17:48
  • try doing `null` instead of `{}` in that case, also, I think you cannot drop the other existing properties, like subnet CIDR `addressPrefix` – 4c74356b41 Aug 20 '20 at 06:06