Skip to content

Commit

Permalink
pcfuncs don't use keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcfarland committed Jun 19, 2024
1 parent fdee967 commit ac727e2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion deployment/terraform/resources/functions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ resource "azurerm_function_app" "pcfuncs" {
os_type = "linux"
version = "~4"
site_config {
linux_fx_version = "PYTHON|3.8"
linux_fx_version = "PYTHON|3.9"
use_32_bit_worker_process = false
ftps_state = "Disabled"

Expand Down
6 changes: 6 additions & 0 deletions deployment/terraform/resources/storage_account.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ resource "azurerm_storage_table" "ipexceptionlist" {
name = "ipexceptionlist"
storage_account_name = azurerm_storage_account.pc.name
}

# TEMP to net mess up other work!
resource "azurerm_storage_table" "blobstoragebannedip" {
name = "blobstoragebannedip"
storage_account_name = azurerm_storage_account.pc.name
}
27 changes: 11 additions & 16 deletions pccommon/pccommon/blob.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
from typing import Dict, Optional, Union

from azure.identity import DefaultAzureCredential
from azure.identity import ManagedIdentityCredential
from azure.storage.blob import ContainerClient

from pccommon.constants import AZURITE_ACCOUNT_KEY


def get_container_client(
container_url: str,
account_key: Optional[str] = None,
) -> ContainerClient:
credential: Optional[Union[str, Dict[str, str], DefaultAzureCredential]] = None
if account_key:
# Handle Azurite
if container_url.startswith("http://azurite:"):
credential = {
"account_name": "devstoreaccount1",
"account_key": account_key,
}
else:
raise ValueError(
"Non-azurite account key provided. "
"Account keys can only be used with Azurite emulator."
)
credential: Optional[Union[Dict[str, str], ManagedIdentityCredential]] = None
# Handle Azurite
if container_url.startswith("http://azurite:"):
credential = {
"account_name": "devstoreaccount1",
"account_key": AZURITE_ACCOUNT_KEY,
}
else:
credential = DefaultAzureCredential()
credential = ManagedIdentityCredential()

return ContainerClient.from_container_url(container_url, credential=credential)
3 changes: 0 additions & 3 deletions pcfuncs/funclib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@

class BaseExporterSettings(BaseSettings):
api_root_url: str = "https://planetarycomputer.microsoft.com/api/data/v1"

output_storage_url: str
output_account_key: Optional[str] = None

def get_container_client(self) -> ContainerClient:
return get_container_client(
self.output_storage_url,
account_key=self.output_account_key,
)

def get_register_url(self, data_api_url_override: Optional[str] = None) -> str:
Expand Down
2 changes: 0 additions & 2 deletions pcfuncs/image/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class ImageSettings(BaseExporterSettings):
def get_container_client(self) -> ContainerClient:
return get_container_client(
self.output_storage_url,
sas_token=self.output_sas,
account_key=self.output_account_key,
)

def get_register_url(self, data_api_url_override: Optional[str] = None) -> str:
Expand Down

0 comments on commit ac727e2

Please sign in to comment.