Skip to content

Instantly share code, notes, and snippets.

@sebug
Last active February 3, 2018 15:49
Show Gist options
  • Save sebug/3686fefc9e7296a9449896a1f5136d05 to your computer and use it in GitHub Desktop.
Save sebug/3686fefc9e7296a9449896a1f5136d05 to your computer and use it in GitHub Desktop.

Sample ASP.NET Core app

This is a small, container-ready version of an API consumer

export API_CONSUMER_BaseUrl=...
export API_CONSUMER_ExternalApplicationCode=...
export API_CONSUMER_PreSharedKey=...
export API_CONSUMER_EventCode=...

You can run the container locally to test:

docker run -d -e API_CONSUMER_BaseUrl -e API_CONSUMER_ExternalApplicationCode -e API_CONSUMER_PRESHAREDKEY -e API_CONSUMER_EventCode -p 1493:80/tcp  api-consumer:1.0.0

On Container instances

az group create --name sampleContainerRegistryGroup --location westeurope
az acr create --resource-group sampleContainerRegistryGroup --name sampleContainerRegistry --sku Basic
az acr update -n sampleContainerRegistry --admin-enabled true
az acr login --name sampleContainerRegistry
az acr list --resource-group sampleContainerRegistryGroup --query "[].{acrLoginServer:loginServer}" --output table
docker tag sample-api-consumer:1.0.0 samplecontainerregistry.azurecr.io/sample-api-consumer:1.0.0
docker push samplecontainerregistry.azurecr.io/sample-api-consumer:1.0.0
az acr credential show --name sampleContainerRegistry --query "passwords[0].value"

Note - I actually had to use password 2 here

az provider register --namespace Microsoft.ContainerInstance
az container create --resource-group sampleContainerRegistryGroup --name sample-api-consumer --image samplecontainerregistry.azurecr.io/sample-api-consumer:1.0.0 --cpu 1 --memory 1 --registry-password ... --ip-address public --ports 80 --environment-variables API_CONSUMER_BaseUrl=... API_CONSUMER_ExternalApplicationCode=... API_CONSUMER_PRESHAREDKEY=... API_CONSUMER_EventCode=...

az container logs --resource-group sampleContainerRegistryGroup --name sample-api-consumer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment