Skip to content

Commit

Permalink
Changes needed to support Azure Container Apps
Browse files Browse the repository at this point in the history
  • Loading branch information
abhahn committed Jul 8, 2024
1 parent fda2173 commit 3cfc1fa
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 55 deletions.
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.venv
.env
Dockerfile
.dockerignore
frontend/node_modules
File renamed without changes.
5 changes: 0 additions & 5 deletions WebApp.dockerignore

This file was deleted.

7 changes: 6 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ def create_app():

@bp.route("/")
async def index():
identity_provider_enabled = "false"
if request.headers.get("X-Ms-Client-Principal"):
identity_provider_enabled = "true"

return await render_template(
"index.html",
title=app_settings.ui.title,
favicon=app_settings.ui.favicon
favicon=app_settings.ui.favicon,
identity_provider_enabled=identity_provider_enabled
)


Expand Down
13 changes: 9 additions & 4 deletions frontend/src/pages/chat/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ const Chat = () => {
setShowAuthMessage(false)
return
}
const userInfoList = await getUserInfo()
if (userInfoList.length === 0 && window.location.hostname !== '127.0.0.1') {
setShowAuthMessage(true)
} else {
if (document.currentScript?.getAttribute("identityProviderEnabled") == "true"){
setShowAuthMessage(false)
}
else {
const userInfoList = await getUserInfo()
if (userInfoList.length === 0 && window.location.hostname !== '127.0.0.1') {
setShowAuthMessage(true)
} else {
setShowAuthMessage(false)
}
}
}

let assistantMessage = {} as ChatMessage
Expand Down
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="icon" type="image/x-icon" href="{{ favicon }}" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{ title }}</title>
<script type="module" crossorigin src="/assets/index-2e11eaf6.js"></script>
<script type="module" crossorigin src="/assets/index-2e11eaf6.js" identityProviderEnabled="{{ identity_provider_enabled }}"></script>
<link rel="stylesheet" href="/assets/index-61492790.css">
</head>
<body>
Expand Down
47 changes: 3 additions & 44 deletions tests/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import pytest
from azure.identity import AzureCliCredential
from azure.keyvault.secrets import SecretClient
from pydantic.alias_generators import to_snake


VAULT_NAME = os.environ.get("VAULT_NAME")
Expand All @@ -18,52 +17,12 @@ def secret_client() -> SecretClient:


@pytest.fixture(scope="module")
def dotenv_template_params_from_kv(secret_client: SecretClient) -> dict[str, str]:
def dotenv_template_params(secret_client: SecretClient) -> dict[str, str]:
secrets_properties_list = secret_client.list_properties_of_secrets()
secrets = {}
for secret in secrets_properties_list:
secret_name = to_snake(secret.name).upper()
secrets[secret_name] = secret_client.get_secret(secret.name).value

return secrets


@pytest.fixture(scope="module")
def dotenv_template_params_from_env() -> dict[str, str]:
def get_and_unset_variable(var_name):
# we need this function to ensure that the environment is clean before
# testing with generated dotenv files.
var_value = os.getenv(var_name)
os.environ[var_name] = ""
return var_value
secrets[secret.name] = secret_client.get_secret(secret.name).value

env_secrets = [
"AZURE_COSMOSDB_ACCOUNT",
"AZURE_COSMOSDB_ACCOUNT_KEY",
"AZURE_COSMOSDB_CONVERSATIONS_CONTAINER",
"AZURE_COSMOSDB_DATABASE",
"AZURE_OPENAI_EMBEDDING_NAME"
"AZURE_OPENAI_ENDPOINT",
"AZURE_OPENAI_MODEL",
"AZURE_OPENAI_KEY",
"AZURE_SEARCH_INDEX",
"AZURE_SEARCH_KEY",
"AZURE_SEARCH_QUERY",
"AZURE_SEARCH_SERVICE",
"ELASTICSEARCH_EMBEDDING_MODEL_ID",
"ELASTICSEARCH_ENCODED_API_KEY",
"ELASTICSEARCH_ENDPOINT",
"ELASTICSEARCH_INDEX",
"ELASTICSEARCH_QUERY"
]

return {s: get_and_unset_variable(s) for s in env_secrets}

return secrets

@pytest.fixture(scope="module")
def dotenv_template_params(request, use_keyvault_secrets):
if use_keyvault_secrets:
return request.getfixturevalue("dotenv_template_params_from_kv")

return request.getfixturevalue("dotenv_template_params_from_env")

0 comments on commit 3cfc1fa

Please sign in to comment.