Skip to content

Commit

Permalink
Merge pull request #12 from Azure-Samples/diberry/1004-composable
Browse files Browse the repository at this point in the history
Scenario 2 - full az cli script
  • Loading branch information
diberry authored Oct 4, 2022
2 parents a748753 + 42be20c commit a56dcf2
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions 2-Deploy-basic-app-to-azure/setup-in-sandbox.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

# All resources and resource group will have the same name.

# Prereqs
# - Must have local copy/clone of this sample repo and run this script from root of project (not root of repo)
# - Must have Azure CLI installed and cached signon (az login) - Az CLI is available from Learn sandbox terminal

# Learn sandbox provides
# - Free `Concierge subscription` with ability to create these exact resources
# - Tenant ID: 604c1504-c6a3-4080-81aa-b33091104187
# - Resource group

# With Bash and Azure CLI
# - Create Application Insights resource
# - Create App Service resource and plan, deploy sample code
# - Connect App Insights to App Service

# If you need to switch tenant, use this command
# az login -t 604c1504-c6a3-4080-81aa-b33091104187

#----------------------------------------------------------------------------------------
# DON'T CHANGE ANYTHING BELOW THIS LINE
#----------------------------------------------------------------------------------------

# <content_fullscript>

# Get Sandbox resource group provided for you
RESOURCEGROUPSTRING=$(az group list --query "[0].name")
RESOURCEGROUPNAME=`sed -e 's/^"//' -e 's/"$//' <<<"$RESOURCEGROUPSTRING" `

# Show resource group name
printf '%s \n' "$RESOURCEGROUPNAME"

# Silently install AZ CLI extensions if needed
# on older versions
echo "Allow extensions to auto-install"
az config set extension.use_dynamic_install=yes_without_prompt

echo "Create app insights"
az monitor app-insights component create --resource-group "$RESOURCEGROUPNAME" --location westus --app js-rentals

echo "Create web app and its plan"
az webapp up --resource-group "$RESOURCEGROUPNAME" --location westus3 --name js-rentals --os-type "Linux" --runtime "node|14-lts"

echo "Connect web app to app insights"
az monitor app-insights component connect-webapp --resource-group "$RESOURCEGROUPNAME" --app js-rentals --web-app js-rentals

# </content_fullscript>

0 comments on commit a56dcf2

Please sign in to comment.