Overview
In some cases, manually importing and configuring subnets for each azure environment is not desirable due to frequent changes of subnets in azure. This article discusses how to write a recurring job to programmatically import azure environment subnets in CMP.
Considerations
The Azure resource handler and is already configured in CMP.
Procedure
Step 1 Add a recurring job
Go to Admin → Reccurings job
Add a new recurring job from Action
Fill the rest of the form
Add this code
from resourcehandlers.azure_arm.models import AzureArmHandler def run(job, logger=None): azure_handler = AzureArmHandler.objects.get(id=00) #replace 00 with ID of your Azure RH envs = azure_handler.environment_set.all() for env in envs: azure_handler.sync_subnets(env=env) return "" "" ""
Step 2 Schedule the recurring job for a specific time to run
From the Admin → Recurring jobs → Select the recurring job you added in Step #1
Click on the pencil to edit the schedule
Provide a cron schedule https://crontab.guru/
0 Comments