@Abduazim Sobitov Thank you for reaching out to Microsoft Q&A. Based on the above shared information We have understood that you have multiple app services and multiple subnets in a single Vnet under a single resource group.
Using PowerShell script, you want to create access restriction rules to every individual app with all the subnets in that particular Vnet. I have written the below script
$resourcegroup="<ResourceGroupName>" #Resource Group Name
$appList= Get-AzWebApp -ResourceGroupName $resourcegroup #list all webapp in that particular resource group
$virtualNetwork= Get-AzVirtualNetwork -ResourceGroupName $resourcegroup #list all the virtual network in that resource group
foreach( $item in $appList.name){
foreach( $subnet in $virtualNetwork.Subnets.name){
az webapp config access-restriction add -g $resourcegroup -n $item --rule-name "Allow_$($item)" --action Allow --vnet-name $virtualNetwork.Name --subnet $subnet --vnet-resource-group $resourcegroup --priority 300
}
}
I have tested the above script it is working from my end, and I would suggest you validate from your end as well.
Here is the sample output screenshot Post running the above script:
Feel free to reach back to me if you have any further questions on this.