|
| 1 | +--- |
| 2 | +title: Enable features on a schedule in a Python application |
| 3 | +titleSuffix: Azure App Configuration |
| 4 | +description: Learn how to enable feature flags on a schedule in a Python application by using time window filters. |
| 5 | +ms.service: azure-app-configuration |
| 6 | +ms.devlang: python |
| 7 | +author: mrm9084 |
| 8 | +ms.author: mametcal |
| 9 | +ms.topic: how-to |
| 10 | +ms.custom: mode-other, devx-track-python |
| 11 | +ms.date: 07/09/2025 |
| 12 | +--- |
| 13 | + |
| 14 | +# Enable features on a schedule in a Python application |
| 15 | + |
| 16 | +In this guide, you use the time window filter to enable a feature on a schedule for a Python application. |
| 17 | + |
| 18 | +The example used is based on the Python application introduced in the feature management [quickstart](./quickstart-feature-flag-python.md). Before proceeding further, complete the quickstart to create a Python application with a *Beta* feature flag. Once completed, you must [add a time window filter](./howto-timewindow-filter.md) to the *Beta* feature flag in your App Configuration store. |
| 19 | + |
| 20 | +## Prerequisites |
| 21 | + |
| 22 | +- Create a [Python application with a feature flag](./quickstart-feature-flag-python.md). |
| 23 | +- [Add a time window filter to the feature flag](./howto-timewindow-filter.md) |
| 24 | + |
| 25 | +## Use the time window filter |
| 26 | + |
| 27 | +You've added a time window filter for your *Beta* feature flag in the prerequisites. Next, you'll use the feature flag with the time window filter in your Python application. |
| 28 | + |
| 29 | +When you create a feature manager, the built-in feature filters are automatically added to its feature filter collection. |
| 30 | + |
| 31 | +``` python |
| 32 | +from featuremanagement import FeatureManager |
| 33 | + |
| 34 | +fm = FeatureManager(provider) |
| 35 | +``` |
| 36 | + |
| 37 | +## Time window filter in action |
| 38 | + |
| 39 | +When you run the application, the configuration provider loads the *Beta* feature flag from Azure App Configuration. The result of the `is_enabled("Beta")` method will be printed to the console. If your current time is earlier than the start time set for the time window filter, the *Beta* feature flag will be disabled by the time window filter. |
| 40 | + |
| 41 | +You'll see the following console outputs. |
| 42 | + |
| 43 | +``` bash |
| 44 | +Beta is enabled: false |
| 45 | +Beta is enabled: false |
| 46 | +Beta is enabled: false |
| 47 | +Beta is enabled: false |
| 48 | +Beta is enabled: false |
| 49 | +Beta is enabled: false |
| 50 | +``` |
| 51 | + |
| 52 | +Once the start time has passed, you'll notice that the *Beta* feature flag is enabled by the time window filter. |
| 53 | + |
| 54 | +You'll see the console outputs change as the *Beta* is enabled. |
| 55 | + |
| 56 | +``` bash |
| 57 | +Beta is enabled: false |
| 58 | +Beta is enabled: false |
| 59 | +Beta is enabled: false |
| 60 | +Beta is enabled: false |
| 61 | +Beta is enabled: false |
| 62 | +Beta is enabled: false |
| 63 | +Beta is enabled: true |
| 64 | +Beta is enabled: true |
| 65 | +Beta is enabled: true |
| 66 | +Beta is enabled: true |
| 67 | +``` |
| 68 | + |
| 69 | +If recurrence is enabled when you set up the time window filter, the console outputs will change to `Beta is enabled: false` once your current time passes the end time you set in the time window filter. However, it will change to `Beta is enabled: true` again according to your recurrence settings and continue this pattern until the recurrence expiration time, if set. |
| 70 | + |
| 71 | +## Next steps |
| 72 | + |
| 73 | +To learn more about the feature filters, continue to the following documents. |
| 74 | + |
| 75 | +> [!div class="nextstepaction"] |
| 76 | +> [Enable conditional features with feature filters](./howto-feature-filters.md) |
| 77 | +
|
| 78 | +> [!div class="nextstepaction"] |
| 79 | +> [Roll out features to targeted audience](./howto-targetingfilter.md) |
| 80 | +
|
| 81 | +For the full feature rundown of the Python feature management library, continue to the following document. |
| 82 | + |
| 83 | +> [!div class="nextstepaction"] |
| 84 | +> [Python Feature Management](./feature-management-python-reference.md) |
0 commit comments