Skip to content

Commit

Permalink
Move check for AZURE_PUBLIC_NETWORK_ACCESS (Azure-Samples#2209)
Browse files Browse the repository at this point in the history
* Update prepdocs.sh to set the AZURE_USE_AUTHENTICATION correctly based on the environment equivalent

* resolve conversation

* Move check into prepdocs.py

---------

Co-authored-by: Richard Grey <[email protected]>
  • Loading branch information
pamelafox and rgrey authored Dec 2, 2024
1 parent 1be8653 commit e90920f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 0 additions & 1 deletion app/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@

@bp.route("/")
async def index():
# TODO: use msal loginRedirect on a blankish page
return await bp.send_static_file("index.html")


Expand Down
7 changes: 5 additions & 2 deletions app/backend/prepdocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ async def main(strategy: Strategy, setup_index: bool = True):

if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Prepare documents by extracting content from PDFs, splitting content into sections, uploading to blob storage, and indexing in a search index.",
epilog="Example: prepdocs.py '.\\data\*' -v",
description="Prepare documents by extracting content from PDFs, splitting content into sections, uploading to blob storage, and indexing in a search index."
)
parser.add_argument("files", nargs="?", help="Files to be processed")

Expand Down Expand Up @@ -302,6 +301,10 @@ async def main(strategy: Strategy, setup_index: bool = True):

load_azd_env()

if os.getenv("AZURE_PUBLIC_NETWORK_ACCESS") == "Disabled":
logger.error("AZURE_PUBLIC_NETWORK_ACCESS is set to Disabled. Exiting.")
exit(0)

use_int_vectorization = os.getenv("USE_FEATURE_INT_VECTORIZATION", "").lower() == "true"
use_gptvision = os.getenv("USE_GPT4V", "").lower() == "true"
use_acls = os.getenv("AZURE_ADLS_GEN2_STORAGE_ACCOUNT") is not None
Expand Down
8 changes: 0 additions & 8 deletions scripts/prepdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@

echo 'Running "prepdocs.py"'

AZURE_USE_AUTHENTICATION=$(azd env get-value AZURE_PUBLIC_NETWORK_ACCESS)
AZURE_PUBLIC_NETWORK_ACCESS=$(azd env get-value AZURE_PUBLIC_NETWORK_ACCESS)

if [ -n "$AZURE_USE_AUTHENTICATION" ] && [ "$AZURE_PUBLIC_NETWORK_ACCESS" = "Disabled" ]; then
echo "AZURE_PUBLIC_NETWORK_ACCESS is set to Disabled. Exiting."
exit 0
fi

additionalArgs=""
if [ $# -gt 0 ]; then
additionalArgs="$@"
Expand Down

0 comments on commit e90920f

Please sign in to comment.