This account was created and is owned by a real human, however, be advised that THIS REPO WAS AUTONOMOUSLY PUBLISHED BY AN AI via execution of ./01_create_github_repo.sh --personal --public
This repository contains a collection of Python scripts for interacting with the Cloudflare API to manage DNS records. It focuses particularly on automating the addition and verification of Microsoft 365 MX records, which are required for properly configuring email services with Microsoft 365.
- Add Microsoft 365 MX records to Cloudflare-managed domains
- Verify successful MX record creation and propagation
- Automatically extract the current Microsoft 365 MX record format from official documentation
- Comprehensive verification against both Cloudflare API and Google DNS
01_create_github_repo.sh- Creates and initializes the GitHub repository02_create_venv.sh- Sets up a Python virtual environment for the project03_requirements.txt- Lists Python package dependencies04_load_requirements.sh- Installs the required dependencies
05_add_M365_mx_record.py- Adds a Microsoft 365 MX record to a specified domain using the Cloudflare API06_verify_M365_mx_record.py- Verifies that the MX record was successfully added and has propagated to public DNS07_add_M365_txt_verification_record.py- Adds the Microsoft 365 TXT domain verification record using the Cloudflare API. It reads the necessary record details from the output file (03.output.powershell.output.txt) generated by the ms_graph_ps repository.08_verify_M365_txt_verification_record.py- Verifies that the TXT verification record was successfully added and has propagated to public DNS, using the same input file as script07to determine the expected value.09_process_M365_dns_records.py- Processes Microsoft 365 DNS records from the PowerShell output and compares them to existing Cloudflare records, offering options to add/update each record interactively.10_add_dns_record.py- Adds a DNS record to Cloudflare with special handling for SRV records and other record types.11_verify_add_dns_record.py- Verifies that a DNS record was correctly added by checking both Cloudflare and public DNS.12_delete_dns_record.py- Deletes a DNS record from Cloudflare.13_verify_delete_dns_record.py- Verifies that a DNS record was successfully deleted from Cloudflare.14_review_dns_records.py- Interactive tool to review all DNS records in a Cloudflare zone, with options to verify or delete each record.
15_configure_vercel_web_deployment.py- Configures the necessary A record (pointing to76.76.21.21) for a Vercel web deployment on the root domain.- Usage:
./15_configure_vercel_web_deployment.py yourdomain.com [--debug]
- Usage:
16_verify_vercel_web_propagation.py- Verifies that the Vercel A record has propagated to public DNS (Google, Cloudflare, Quad9) and optionally checks against the Cloudflare API.- Reads record ID from
15.output.record_id.txtfor API check. - Usage:
./16_verify_vercel_web_propagation.py <zone_domain>
- Reads record ID from
17_add_domain_cname.py- Adds a general CNAME record to the specified domain.- Usage:
./17_add_domain_cname.py <zone_domain> <cname_name> <cname_target> [--debug](e.g.,./17_add_domain_cname.py example.com www target.example.com)
- Usage:
18_verify_cname_propagation.py- Verifies that a CNAME record has propagated to public DNS (Google, Cloudflare, Quad9) and optionally checks against the Cloudflare API.- Reads record details from
17.output.record_details.json. - Usage:
./18_verify_cname_propagation.py <zone_domain>
- Reads record details from
- Clone this repository
- Run
./02_create_venv.shto create the Python virtual environment - Run
./04_load_requirements.shto install dependencies - Create a
.envfile in your home directory with the following content:CLOUDFLARE_API_TOKEN=your_api_token_here CLOUDFLARE_ZONE_ID=your_zone_id_here
This repository works in conjunction with the ms_graph_ps repository. The recommended workflow involves steps from both repositories:
-
Add M365 MX Record (using this
cloudflare_api_clientrepo):- Activate the virtual environment:
source ./cloudflare_api_client-venv/bin/activate - Run
./05_add_M365_mx_record.py yourdomain.com. - This adds the primary mail exchange record required by Microsoft 365 to your Cloudflare DNS.
- Activate the virtual environment:
-
Verify MX Record Propagation:
- Run
./06_verify_M365_mx_record.py yourdomain.com. - This checks Cloudflare and public DNS to ensure the MX record is correctly set up. Wait a few minutes if verification fails initially, as DNS propagation takes time.
- Run
-
Add Domain & Get TXT Record (using
ms_graph_ps):- Go to your local clone of the
ms_graph_psrepository (cd ../ms_graph_ps). - Run
./03_powershell_add_domain.sh yourdomain.com. - This script interacts with Microsoft Graph to add the domain to your M365 tenant and generates the required TXT verification record details in
../ms_graph_ps/03.output.powershell.output.txt.
- Go to your local clone of the
-
Add TXT Record to Cloudflare (using this
cloudflare_api_clientrepo):- Navigate back to this
cloudflare_api_clientdirectory (cd ../cloudflare_api_client). - Ensure the virtual environment is active:
source ./cloudflare_api_client-venv/bin/activate - Run
./07_add_M365_txt_verification_record.py yourdomain.com. - This script reads the TXT record details from the output file created in step 3 and adds the record to your Cloudflare DNS zone.
- Navigate back to this
-
Verify TXT Record Propagation:
- Run
./08_verify_M365_txt_verification_record.py yourdomain.com. - This script checks both Cloudflare and public DNS (Google) to confirm the TXT record is correctly set up and visible. Wait a few minutes if verification fails initially.
- Run
-
Trigger M365 Verification (using
ms_graph_ps):- Once script
08shows success (especially via Google DNS), go back to your local clone of thems_graph_psrepository (cd ../ms_graph_ps). - Run
./04_powershell_confirm_domain.sh yourdomain.com. - This script uses
Confirm-MgDomainto tell Microsoft 365 to check for the TXT record and complete the domain verification.
- Once script
-
Get M365 Service Records (using
ms_graph_ps):- After step 6 successfully confirms the domain, run
./05_powershell_show_domain_svc_recs.sh yourdomain.com. - This script retrieves the additional DNS records (CNAMEs for Autodiscover/Intune/etc., SRV records for Teams/Skype) needed for full M365 service functionality and saves them to
../ms_graph_ps/05.output.powershell.ouput.txt.
- After step 6 successfully confirms the domain, run
-
Add Service Records to Cloudflare (using this
cloudflare_api_clientrepo):- Navigate back to this
cloudflare_api_clientdirectory (cd ../cloudflare_api_client). - Ensure the virtual environment is active:
source ./cloudflare_api_client-venv/bin/activate - Run
./09_process_M365_dns_records.py yourdomain.com. - This script automatically:
- Cleans and processes the Microsoft 365 DNS records from
../ms_graph_ps/05.output.powershell.output.txt - Compares each record with existing records in your Cloudflare zone
- Prompts you to add or update each record interactively
- Uses scripts 10-13 to add, delete, and verify records as needed
- Cleans and processes the Microsoft 365 DNS records from
- Alternatively, you can use
./14_review_dns_records.py yourdomain.comto review existing records in your Cloudflare zone.
- Navigate back to this
./05_add_M365_mx_record.py yourdomain.comThis will:
- Fetch the current MX record format from Microsoft's documentation
- Create the correct MX record for your domain in Cloudflare
- Return a success message with the API response
./06_verify_M365_mx_record.py yourdomain.comThis will:
- Check the Cloudflare API to verify the record was created correctly
- Check Google DNS (8.8.8.8) to verify the record has propagated to public DNS
- Provide a detailed verification summary
- Resilient to Format Changes: Automatically extracts the current Microsoft 365 MX record format from official documentation rather than hardcoding it
- Dual Verification: Checks both Cloudflare configuration and public DNS propagation
- Detailed Feedback: Provides comprehensive output on verification status
- API Token Security: Uses environment variables for secure credential management
- Python 3.6+
- Cloudflare API Token with DNS edit permissions
- Cloudflare Zone ID for your domain
Please note that this repository is maintained primarily by autonomous AI agents. There is no guarantee that the human developer that created and owns this account will review your issues or pull requests.
An AI agent may review submitted issues and pull requests. However, there is no guarantee that the AI will choose to address them, nor that any AI-driven changes will be satisfactory.
The AI first screens all submissions for malicious intent or content. Malicious issues or pull requests will be reported to the various warranted channels.