Skip to content

Commit

Permalink
remove development azurite keys
Browse files Browse the repository at this point in the history
  • Loading branch information
joshimai committed Aug 1, 2024
1 parent d2b46c9 commit 21c42f8
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ This project uses a variation on [scripts to rule them all](https://github.com/g

#### Environment setup and building images

Before setting up the local environment, ensure that you have set the AZURITE_ACCOUNT_KEY environment variable.
The account key can be found in the [Azurite GitHub repository](https://github.com/Azure/Azurite?tab=readme-ov-file#usage-with-azure-storage-sdks-or-tools)

For example, you can set the environment variable in your terminal with:
```console
> export AZURITE_ACCOUNT_KEY=<azurite_account_key>
```

To set up a local environment, use

```console
Expand Down
14 changes: 8 additions & 6 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@ services:
- TILER_HREF=http://localhost:8080/data/

# Azure Storage
- AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig

- PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig

- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist

# Redis
Expand Down Expand Up @@ -92,19 +93,20 @@ services:
- WORKERS_PER_CORE=1

# Azure Storage
- AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_COLLECTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_COLLECTION_CONFIG__TABLE_NAME=collectionconfig

- PCAPIS_CONTAINER_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_CONTAINER_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_CONTAINER_CONFIG__TABLE_NAME=containerconfig

- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_URL=http://azurite:10002/devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_NAME=devstoreaccount1
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
- PCAPIS_IP_EXCEPTION_CONFIG__ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
- PCAPIS_IP_EXCEPTION_CONFIG__TABLE_NAME=ipexceptionlist

# Redis
Expand Down
11 changes: 5 additions & 6 deletions pc-funcs.dev.env
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
AzureWebJobsStorage=DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azurite:10000/devstoreaccount1;QueueEndpoint=http://azurite:10001/devstoreaccount1;TableEndpoint=http://azurite:10002/devstoreaccount1;
WEBSITE_HOSTNAME=funcs:8083

ANIMATION_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/animations"
ANIMATION_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

ANIMATION_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1"
ANIMATION_TILE_REQUEST_CONCURRENCY=2

IMAGE_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/images"
IMAGE_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

IMAGE_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1"
IMAGE_TILE_REQUEST_CONCURRENCY=2

STORAGE_ACCOUNT_URL=https://pctapisstagingsa.table.core.windows.net/
BANNED_IP_TABLE=blobstoragebannedip
LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4
LOG_ANALYTICS_WORKSPACE_ID=78d48390-b6bb-49a9-b7fd-a86f6522e9c4

AZURITE_ACCOUNT_KEY=${AZURITE_ACCOUNT_KEY}
7 changes: 3 additions & 4 deletions pccommon/pccommon/constants.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

from opencensus.trace.attributes_helper import COMMON_ATTRIBUTES

DEFAULT_COLLECTION_CONFIG_TABLE_NAME = "collectionconfig"
Expand Down Expand Up @@ -34,7 +36,4 @@
# This is the Azurite storage account key.
# This is not a key for a real Storage Account and is publicly accessible
# on Azurite's GitHub repo. This is used only in development.
AZURITE_ACCOUNT_KEY = (
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUz"
"FT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
)
AZURITE_ACCOUNT_KEY: str = os.environ.get("AZURITE_ACCOUNT_KEY", "")
5 changes: 3 additions & 2 deletions pcfuncs/tests/ipban/test_ipban.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from ipban.models import UpdateBannedIPTask
from pytest_mock import MockerFixture

from pccommon.constants import AZURITE_ACCOUNT_KEY

MOCK_LOGS_QUERY_RESULT = [("192.168.1.1", 8000), ("192.168.1.4", 12000)]
TEST_ID = str(uuid.uuid4()).replace("-", "") # dash is not allowed in table name
TEST_BANNED_IP_TABLE = f"testblobstoragebannedip{TEST_ID}"
Expand Down Expand Up @@ -58,8 +60,7 @@ def mock_clients(
logs_query_client.query_workspace.return_value = mock_response
CONNECTION_STRING: str = (
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsu"
"Fq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"
f"AccountKey={AZURITE_ACCOUNT_KEY};"
"TableEndpoint=http://azurite:10002/devstoreaccount1;"
)

Expand Down
5 changes: 2 additions & 3 deletions scripts/bin/setup_azurite.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pccommon.config.collections import CollectionConfig, CollectionConfigTable
from pccommon.config.containers import ContainerConfig, ContainerConfigTable
from pccommon.constants import (
AZURITE_ACCOUNT_KEY,
DEFAULT_COLLECTION_CONFIG_TABLE_NAME,
DEFAULT_CONTAINER_CONFIG_TABLE_NAME,
DEFAULT_IP_EXCEPTION_CONFIG_TABLE_NAME,
Expand All @@ -27,9 +28,7 @@

AZURITE_CONNECT_STRING = (
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
"AccountKey="
"Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq"
"/K1SZFPTOtr/KBHBeksoGMGw==;"
f"AccountKey={AZURITE_ACCOUNT_KEY};"
"BlobEndpoint=http://azurite:10000/devstoreaccount1;"
"QueueEndpoint=http://azurite:10001/devstoreaccount1;"
"TableEndpoint=http://azurite:10002/devstoreaccount1;"
Expand Down

0 comments on commit 21c42f8

Please sign in to comment.