It sounds like the Just-In-Time (JIT) policy in Microsoft Defender for Cloud might be causing the issue. Here are a few steps you can take to prevent the rule from resetting:
- Remove JIT Access: Navigate to Microsoft Defender for Cloud -> Workload protection -> Just in time access -> Configured. Select the VM and remove it from the configuration.
- Delete JIT Policy via API: If the JIT policy persists, you can delete it using the Azure portal API playground. List all the JIT policies under your subscription and delete the one associated with your VM.
- Adjust Network Security Group (NSG) Rules: Ensure that your NSG rules have higher priority than the JIT policy. This might help in preventing the automatic reset.
These steps should help in preventing the automatic reset of your Inbound Port Rules. If you need more detailed instructions, you can find them here.
Let me know if you need further assistance.