microsoft / planetary-computer-apis

Planetary Computer APIs
MIT License
105 stars 28 forks source link

Azure Function App which runs periodically to aggregate the bytes read per IP address over a window of time #215

Closed elayrocks closed 5 months ago

elayrocks commented 5 months ago

Description

This PR is the first step in implementing data consumption quotas for SAS API Token Issuance. I created a new Azure Function App which runs periodically to execute a KQL query against Storage Account Blob Logs to aggregate the bytes read per IP address over a window of time (e.g., 24 hours). IPs which have read above a certain threshold will be added to an Azure storage table called blob storage banned ip which serves as a temporary ban list.

Please refer to the design doc for more details.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Unit test uses mocked response from log query client and writes test data to azurite. The integration/E2E test queries the log analytics workspace and writes to test table in storage account and deletes it after testing is complete.

Make sure correct roles have been assigned, run ./scripts/server to start azurite service and scripts/test --funcs [--no-integration] to run unit tests. and integration tests (optionally).

Checklist:

Please delete options that are not relevant.