From 843da3bf1e3bc4f0db6ba6d4e4aef7d4ebfb131f Mon Sep 17 00:00:00 2001 From: Rodrigo Liberoff Date: Mon, 20 May 2024 18:18:55 +0200 Subject: [PATCH] @rliberoff/create bash intall script (#40) Create install bash script --- .gitignore | 5 ++- infra/README.md | 18 +++++++++- install/install_linux.sh | 76 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100755 install/install_linux.sh diff --git a/.gitignore b/.gitignore index 2fc9fe8..482385d 100644 --- a/.gitignore +++ b/.gitignore @@ -416,4 +416,7 @@ src/AIHub/appsettings.Development.json *.tfstate *.tfstate.* -local.settings.json \ No newline at end of file +local.settings.json + +# Ignore hidden folder for AI Hub Installation +**/.aihub diff --git a/infra/README.md b/infra/README.md index 31257bc..bcc5bf5 100644 --- a/infra/README.md +++ b/infra/README.md @@ -8,7 +8,7 @@ Before deploying and installing the Azure AI Hub, please ensure the following pr - During deployment, the script will create two application registrations on Microsoft Entra ID. Please verify that your user account has the necessary privileges. - The Azure AI Hub uses various cognitive services like Azure Computer Vision, Azure Speech Service or Azure Document Intelligence. To deploy these Cognitive Services, you must manually accept the "Responsible AI" terms. This can currently only be done by deploying any of these services from the Azure Portal. -## Deploying the infrastructure +## Deploying the infrastructure - Windows Run the following command to deploy the infrastructure: @@ -18,6 +18,22 @@ az account set -s powershell -Command "iwr -useb https://raw.githubusercontent.com/azure/aihub/master/install/install.ps1 | iex" ``` +## Deploying the infrastructure - Linux + +For installation on Linux, we recommend using `Ubuntu 22.04` or a newer version. Before executing the installation script, ensure that the following applications are installed and up-to-date: + +- `curl`, version `7.x` or higher. +- `jq`, version `1.6` or higher. +- `unzip`, version `6.x` or higher. + +To deploy the infrastructure, execute the following command: + +```bash +az login +az account set -s +bash -c "$(curl -fsSL https://raw.githubusercontent.com/azure/aihub/master/install/install_linux.sh)" +``` + ## Manual steps For details on manual deployment, please refer to the [Deployment](https://azure.github.io/aihub/docs/deployment/) section in the Azure AI Hub documentation. diff --git a/install/install_linux.sh b/install/install_linux.sh new file mode 100755 index 0000000..f8c8192 --- /dev/null +++ b/install/install_linux.sh @@ -0,0 +1,76 @@ +echo "" +set -e + +# GitHub Org and repo hosting AI Hub +GitHubOrg="azure" +GitHubRepo="aihub" + +AIHubRoot="./.aihub" + +# Set Github request authentication for basic authentication. +if [[ -n GITHUB_USER ]]; then + basicAuth=$(echo -n "$GITHUB_USER:$GITHUB_TOKEN" | base64) + githubHeader="Authorization: Basic $basicAuth" +else + githubHeader="" +fi + +echo "Installing AI Hub..." + +# Create Dapr Directory +echo "Creating AIHubRoot directory" +mkdir -p "$AIHubRoot" +if [ ! -d "$AIHubRoot" ]; then + echo "Warning: Please visit https://azure.github.io/aihub/docs/ for instructions on how to install without admin rights." + echo "Cannot create $AIHubRoot" >&2 + exit 1 +fi + +latest_aihub=$(curl -H "$githubHeader" https://api.github.com/repos/Azure/aihub/releases/latest | jq -r .tag_name) +zipFileUrl="https://github.com/Azure/aihub/releases/download/$latest_aihub/aihub-tf-module.zip" +echo "Downloading $zipFileUrl ..." +zipFilePath="aihub-tf-module.zip" +curl -H "$githubHeader" -H "Accept: application/octet-stream" -L $zipFileUrl --output $zipFilePath + +if [ ! -f "$zipFilePath" ]; then + echo "Failed to download AI Hub - $zipFilePath" >&2 + exit 1 +fi + +# Extract AI Hub to AIHubRoot +echo "Extracting $zipFilePath..." +unzip -o $zipFilePath -d $AIHubRoot + +# Move files to root +mv "$AIHubRoot/home/runner/work/aihub/aihub/release/aihub-tf-module/"* $AIHubRoot + +# Clean up folder +rm -rf "$AIHubRoot/home" + +# Clean up zipfile +echo "Clean up $zipFilePath..." +rm $zipFilePath + +zipFilePath="terraform_1.7.4_linux_386.zip" +zipFileUrl="https://releases.hashicorp.com/terraform/1.7.4/$zipFilePath" +echo "Downloading $zipFileUrl ..." +curl -L $zipFileUrl --output $zipFilePath + +# Extract terraform to $AIHubRoot +echo "Extracting $zipFilePath..." +unzip -o $zipFilePath -d $AIHubRoot + +# Clean up zipfile +echo "Clean up $zipFilePath..." +rm $zipFilePath + +# Use Terraform to deploy AI Hub +echo "Deploying AI Hub..." +cd $AIHubRoot +./terraform init +./terraform apply -auto-approve +cd - + +# Everything is done +echo -e "\nAI Hub deployed successfully." +echo "To get started with AI Hub, please visit https://azure.github.io/aihub ."