Skip to content

Commit

Permalink
Add sample for ACI
Browse files Browse the repository at this point in the history
  • Loading branch information
yangl900 committed Feb 28, 2018
1 parent 6fab46e commit f35e68b
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 0 deletions.
7 changes: 7 additions & 0 deletions samples/azure-container-instance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Upload Azure Container Instances logs to OMS

This template demonstrates a simple use case for uploading nginx access logs to Azure Log Analytics. The nginx container runs in [Azure Container Instances](https://docs.microsoft.com/en-us/azure/container-instances/). Clicking the deploy button will create a nginx container with public IP address and a log2oms container as sidecar that uploads the logs.

<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2Fyangl900%2Fmaster%2Fsamples%2Fazure-container-instance%2Fazuredeploy.json" target="_blank">
<img src="http://azuredeploy.net/deploybutton.png"/>
</a>
142 changes: 142 additions & 0 deletions samples/azure-container-instance/azuredeploy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"containergroupname": {
"type": "string",
"metadata": {
"description": "Name for the container group"
}
},
"OMS_WORKSPACE_ID": {
"type": "string",
"metadata": {
"description": "OMS workspace Id."
}
},
"OMS_WORKSPACE_SECRET": {
"type": "securestring",
"metadata": {
"description": "OMS workspace secret. Find it in Advanced Settings in Azure portal."
}
},
"OMS_LOG_TYPE": {
"type": "string",
"metadata": {
"description": "OMS log type, the table name in Log Analytics."
},
"defaultValue": "nginx_access"
},
"cpuCores": {
"type": "string",
"metadata": {
"description": "The number of CPU cores to allocate to the container."
},
"defaultValue": "1.0"
},
"memoryInGb": {
"type": "string",
"metadata": {
"description": "The amount of memory to allocate to the container in gigabytes."
},
"defaultValue": "1.5"
}
},
"variables": {},
"resources": [
{
"name": "[parameters('containergroupname')]",
"type": "Microsoft.ContainerInstance/containerGroups",
"apiVersion": "2018-02-01-preview",
"location": "eastus",
"properties": {
"containers": [
{
"name": "nginx",
"properties": {
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 0.9,
"memoryInGb": 0.9
}
},
"volumeMounts": [
{
"name": "logs",
"mountPath": "/var/log/nginx",
"readOnly": false
}
]
}
},
{
"name": "log2oms",
"properties": {
"image": "yangl/log2oms",
"resources": {
"requests": {
"cpu": 0.1,
"memoryInGb": 0.1
}
},
"environmentVariables": [
{
"name": "LOG2OMS_WORKSPACE_ID",
"value": "[parameters('OMS_WORKSPACE_ID')]"
},
{
"name": "LOG2OMS_WORKSPACE_SECRET",
"value": "[parameters('OMS_WORKSPACE_SECRET')]"
},
{
"name": "LOG2OMS_LOG_FILE",
"value": "/logs/access.log"
},
{
"name": "LOG2OMS_LOG_TYPE",
"value": "[parameters('OMS_LOG_TYPE')]"
}
],
"volumeMounts": [
{
"name": "logs",
"mountPath": "/logs",
"readOnly": true
}
]
}
}
],
"osType": "Linux",
"ipAddress": {
"type": "Public",
"ports": [
{
"protocol": "tcp",
"port": 80
}
]
},
"volumes": [
{
"name": "logs",
"emptyDir": {}
}
]
}
}
],
"outputs": {
"containerIPv4Address": {
"type": "string",
"value": "[reference(resourceId('Microsoft.ContainerInstance/containerGroups/', parameters('containergroupname'))).ipAddress.ip]"
}
}
}

0 comments on commit f35e68b

Please sign in to comment.