As I’m doing a lot of demos using ElasticSearch, I like to use Azure Container Instances to spin up a new container image. To simplify the creation process, I’m using the Azure CLI in combination with the script below:
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
# these demos use the Azure CLI | |
# install following instructions from here: | |
# https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest | |
# then login: | |
az login | |
# see which subscription is selected | |
# az account show --query name -o tsv | |
# select the subscription you want to use | |
az account set -s "MySub" | |
# create a resource group | |
$resourceGroup = "AciElasticSearchDemo" | |
$location = "westeurope" | |
az group create -n $resourceGroup -l $location | |
# create an elasticsearch container with 4GB RAM and 2 CPUs | |
$containerGroupName = "es-demo" | |
az container create --image elasticsearch:latest --name $containerGroupName -g $resourceGroup ` | |
--ip-address public --dns-name-label es-aci --memory 4 --cpu 2 --ports 9200 | |
# see whether it's finished provisioning yet | |
az container show -g $resourceGroup -n $containerGroupName --query provisioningState -o tsv | |
# get the domain name | |
$fqdn = az container show -g $resourceGroup -n $containerGroupName --query ipAddress.fqdn -o tsv | |
# make a request to elasticsearch to check it's working | |
(Invoke-WebRequest -Uri "http://$($fqdn):9200/?pretty").content |
Remark: this is a copy of one of the scripts found here; https://github.com/markheath/aci-getting-started/blob/master/m1-01-elasticsearch.ps1