|
| 1 | +# Setup Guide |
| 2 | + |
| 3 | +## Prerequisites |
| 4 | + |
| 5 | +- The following tools: |
| 6 | + - [_Docker desktop_](https://docs.docker.com/desktop/install/windows-install/) |
| 7 | + - [_Azure CLI_](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli-windows?tabs=azure-cli) |
| 8 | + - Azure subscription with a few credits |
| 9 | + |
| 10 | +### Build the images |
| 11 | + |
| 12 | +- Change into the example folder (one-line or step-by-step): |
| 13 | + |
| 14 | +```powershell |
| 15 | +cd .\examples\aks\iis-logmonitor |
| 16 | +``` |
| 17 | + |
| 18 | +- Build the Docker image from the Dockerfile in this folder, tag it for Docker Hub, and push: |
| 19 | + |
| 20 | +```powershell |
| 21 | +# build (run from examples/aks/iis-logmonitor) |
| 22 | +docker build -t <dockerhub-username>/iis-logmonitor:latest -f Dockerfile . |
| 23 | +
|
| 24 | +# login to Docker Hub (interactive) |
| 25 | +docker login |
| 26 | +
|
| 27 | +# push |
| 28 | +docker push <dockerhub-username>/iis-logmonitor:latest |
| 29 | +``` |
| 30 | + |
| 31 | +### Create AKS Cluster |
| 32 | + |
| 33 | +> _Run all this from Powershell_ |
| 34 | +
|
| 35 | +- `az login` (if you have multiple subscriptions, make sure you have the right subscription set as default.) |
| 36 | +- cd into `ps-scripts` |
| 37 | +- Update `vars.txt` |
| 38 | +- Run `./rg-create.ps1` to create the resource group. |
| 39 | +- Run `./aks-create.ps1` - the script creates an AKS cluster, adds a Windows node pool and connects to the cluster. |
| 40 | + |
| 41 | +### Deploy the application |
| 42 | + |
| 43 | +```powershell |
| 44 | +./deploy.ps1 |
| 45 | +``` |
| 46 | + |
| 47 | +After a few minutes, check the status of the pods |
| 48 | +```powershell |
| 49 | +kubectl get pods |
| 50 | +NAME READY STATUS RESTARTS AGE |
| 51 | +iislogmonitor-95c488777-fkhgt 1/1 Running 0 2m5s |
| 52 | +``` |
| 53 | +This indicates the pod started successfully — `READY 1/1` and `STATUS Running` show the container is healthy. |
| 54 | + |
| 55 | +Check the service status and external IP, you should get something similar to: |
| 56 | + |
| 57 | +```powershell |
| 58 | +# NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE |
| 59 | +# kubernetes ClusterIP 10.0.0.1 <none> 443/TCP 36m |
| 60 | +# iislogmonitor LoadBalancer 10.0.191.38 52.188.177.226 80:31349/TCP 2m19s |
| 61 | +``` |
| 62 | + |
| 63 | +Access the app using the `http://EXTERNAL-IP` shown in the output, for example:`http://52.188.177.226` |
| 64 | + |
| 65 | +```powershell |
| 66 | +Start-Process "http://52.188.177.226" |
| 67 | +``` |
| 68 | +To stream the container logs from that pod, run: |
| 69 | + |
| 70 | +```powershell |
| 71 | +kubectl logs -f iislogmonitor-95c488777-fkhgt |
| 72 | +``` |
| 73 | + |
| 74 | +### Configure Azure Monitor (Container Insights) |
| 75 | + |
| 76 | +You can enable AKS monitoring (Container Insights) from the Azure portal. Open the following onboarding view and follow the steps to enable monitoring for this cluster (select or create a Log Analytics workspace, then enable): |
| 77 | + |
| 78 | +After onboarding completes you can view container logs, metrics and insights in Azure Monitor > Container insights for the cluster. |
| 79 | + |
| 80 | +To query container logs (Log Analytics) for IIS entries you can run a KQL query in the Log Analytics `Logs` view. Example: |
| 81 | + |
| 82 | +```kql |
| 83 | +// Find In ContainerLogV2 |
| 84 | +ContainerLogV2 |
| 85 | +| where LogMessage contains "W3SVC" |
| 86 | +``` |
| 87 | + |
| 88 | +This returns container log entries that include IIS/W3SVC messages collected by Container Insights. |
| 89 | + |
| 90 | +The screenshots below show the Azure Monitor onboarding and Log Analytics views for this example. |
| 91 | + |
| 92 | + |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +### Clean-up |
| 103 | + |
| 104 | +Clean up by deleting the resource group, in `ps-scripts`, run: `./clean-up.ps1` |
0 commit comments