-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor scripts to avoid anti-patterns, redundancy (#1986)
* Update bicep for ACA * First working version * Support workload profile * Add support for CORS and fix identity for openai * Add aca-host * Make acr unique * Add doc for aca host * Update ACA docs * Remove unneeded bicep files * Revert chanes to infra/main.parameters.json * Fix markdown lint issues * Run frontend build before building docker image * remove symlinks and update scripts with paths relative to its own folder instead of cwd * Merge with main.bicep * output AZURE_CONTAINER_REGISTRY_ENDPOINT * Fix deployment with app service * Improve naming and README * Fix identity name and cost esitmation for aca * Share env vars in bicep and update docs * Revert "remove symlinks and update scripts with paths relative to its own folder instead of cwd" This reverts commit 40287f2. * Add containerapps as a commented out host option * Update app/backend/.dockerignore * Apply suggestions from code review * More steps for deployment guide * Update azure.yaml * Update comment * cleanup bicep files and improve docs * Update condition for running in production for credential * Refactors to scripts * Remove phi changes * Make mypy happy * Add dotenv requirement * Env var tweaks * Fix error handling * Update manageacl.py commands * Doc update * Adding more tests for prepdocs * Fix markdown copy * Fix relative links * Make prepdocs mypy happy * Fix auth_update if check --------- Co-authored-by: yefuwang <[email protected]> Co-authored-by: Yefu Wang <[email protected]>
- Loading branch information
1 parent
106b52b
commit b8f0a74
Showing
42 changed files
with
502 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
import logging | ||
import subprocess | ||
|
||
from dotenv import load_dotenv | ||
|
||
logger = logging.getLogger("scripts") | ||
|
||
|
||
def load_azd_env(): | ||
"""Get path to current azd env file and load file using python-dotenv""" | ||
result = subprocess.run("azd env list -o json", shell=True, capture_output=True, text=True) | ||
if result.returncode != 0: | ||
raise Exception("Error loading azd env") | ||
env_json = json.loads(result.stdout) | ||
env_file_path = None | ||
for entry in env_json: | ||
if entry["IsDefault"]: | ||
env_file_path = entry["DotEnvPath"] | ||
if not env_file_path: | ||
raise Exception("No default azd env file found") | ||
logger.info(f"Loading azd env from {env_file_path}") | ||
load_dotenv(env_file_path, override=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,12 @@ | ||
import os | ||
|
||
from app import create_app | ||
from load_azd_env import load_azd_env | ||
|
||
# WEBSITE_HOSTNAME is always set by App Service, RUNNING_IN_PRODUCTION is set in main.bicep | ||
RUNNING_ON_AZURE = os.getenv("WEBSITE_HOSTNAME") is not None or os.getenv("RUNNING_IN_PRODUCTION") is not None | ||
|
||
if not RUNNING_ON_AZURE: | ||
load_azd_env() | ||
|
||
app = create_app() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,4 @@ beautifulsoup4 | |
types-beautifulsoup4 | ||
msgraph-sdk==1.1.0 | ||
openai-messages-token-helper | ||
python-dotenv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.