Azure Function App for Secret Expiry Notifications
This Azure Function App fetches Azure App Registrations, checks for expiring secrets, and sends email notifications to the owners.
Prerequisites
- Azure Subscription
- Azure CLI
- Python 3.11
- Azure DevOps account
- Self-hosted agent (optional)
Project Structure
azure-function-app
├── aio
│ ├── __init__.py # Contains the main logic for the Azure Function
│ └── function.json # Configuration for the Azure Function
├── local.settings.json # Local configuration settings
├── requirements.txt # Required Python packages
└── README.md # Project documentation
Setup
Local Development
-
Clone the repository:
git clone https://github.com/your-repo/AzFuncAppNotify.git cd AzFuncAppNotify/azure-function-app -
Create local dev environment & Install dependencies: Make sure you have Python3.11 installed, then run:
python3.11 -m venv .venv source .venv/bin/activate pip install -r requirements.txt -
Configure environment variables: Create a local.settings.json file in the root of the function app directory with the following contents
{ "IsEncrypted": false, "Values": { "AzureWebJobsStorage": "", "FUNCTIONS_WORKER_RUNTIME": "python", "AZURE_CLIENT_ID": "", "AZURE_CLIENT_SECRET": "", "AZURE_TENANT_ID": "", "SMTP_SERVER": "", "SMTP_PORT": "", "SMTP_USERNAME": "", "SMTP_PASSWORD": "", "FROM_EMAIL": "", "FROM_NAME": "", "TO_EMAIL": "" } } -
Run the function locally: Use the Azure Functions Core Tools to run the function:
func start
Usage
Once the function is running, you can trigger it by sending an HTTP request to the endpoint provided in the console output. The function will authenticate to the Microsoft Graph API and return the app registrations.
License
This project is licensed under the MIT License.