Skip to content

Commit 2235091

Browse files
committed
Moving cosmosdb quickstart code to samples repo
1 parent cb17e82 commit 2235091

File tree

8 files changed

+152
-25
lines changed

8 files changed

+152
-25
lines changed

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
# Contributing
2-
This project welcomes contributions and suggestions.
3-
4-
## Modules
5-
Module summary
6-
[Module contribution guide](./module/CONTRIBUTE.md)
7-
8-
## Providers
9-
Provider summary
10-
[Provider contribution guide](./provider/CONTRIBUTE.md)
11-
12-
# Contributing
13-
14-
This project welcomes contributions and suggestions. Most contributions require you to agree to a
15-
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
16-
the rights to use your contribution. For details, visit https://cla.microsoft.com.
17-
18-
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
19-
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
20-
provided by the bot. You will only need to do this once across all repos using our CLA.
21-
22-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
23-
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
24-
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
1+
# Contributing
2+
This project welcomes contributions and suggestions.
3+
4+
## Modules
5+
Module summary
6+
[Module contribution guide](./module/CONTRIBUTE.md)
7+
8+
## Providers
9+
Provider summary
10+
[Provider contribution guide](./provider/CONTRIBUTE.md)
11+
12+
# Contributing
13+
14+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
15+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
16+
the rights to use your contribution. For details, visit https://cla.microsoft.com.
17+
18+
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide
19+
a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions
20+
provided by the bot. You will only need to do this once across all repos using our CLA.
21+
22+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
23+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
24+
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This code sets two environment variables: COSMOS_DB_ENDPOINT and COSMOS_DB_MASTERKEY.
2+
# These variables hold the location and key for accessing the database.
3+
# The values for these variables are obtained from the database instance created in main.tf
4+
# This process is known as interpolation.
5+
# To learn more about Terraform interpolation, see https://www.terraform.io/language/v1.1.x/configuration-0-11/interpolation.
6+
7+
resource "azurerm_container_group" "vote_aci" {
8+
name = "vote_aci"
9+
location = azurerm_resource_group.rg.location
10+
resource_group_name = azurerm_resource_group.rg.name
11+
ip_address_type = "public"
12+
dns_name_label = "vote_aci"
13+
os_type = "linux"
14+
15+
container {
16+
name = "vote_aci"
17+
image = "mcr.microsoft.com/azuredocs/azure-vote-front:cosmosdb"
18+
cpu = "0.5"
19+
memory = "1.5"
20+
ports {
21+
port = 80
22+
protocol = "TCP"
23+
}
24+
25+
secure_environment_variables = {
26+
"COSMOS_DB_ENDPOINT" = azurerm_cosmosdb_account.vote_cosmos_db.endpoint
27+
"COSMOS_DB_MASTERKEY" = azurerm_cosmosdb_account.vote_cosmos_db.primary_master_key
28+
"TITLE" = "Azure Voting App"
29+
"VOTE1VALUE" = "Cats"
30+
"VOTE2VALUE" = "Dogs"
31+
}
32+
}
33+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
resource "random_pet" "rg_name" {
2+
prefix = var.resource_group_name_prefix
3+
}
4+
5+
resource "azurerm_resource_group" "rg" {
6+
location = var.resource_group_location
7+
name = random_pet.rg_name.id
8+
}
9+
10+
resource "random_integer" "ri" {
11+
min = 10000
12+
max = 99999
13+
}
14+
15+
resource "azurerm_cosmosdb_account" "vote_cosmos_db" {
16+
name = "tfex-cosmos-db-${random_integer.ri.result}"
17+
location = azurerm_resource_group.rg.location
18+
resource_group_name = azurerm_resource_group.rg.name
19+
offer_type = "Standard"
20+
kind = "GlobalDocumentDB"
21+
22+
consistency_policy {
23+
consistency_level = "BoundedStaleness"
24+
max_interval_in_seconds = 10
25+
max_staleness_prefix = 200
26+
}
27+
28+
geo_location {
29+
location = azurerm_resource_group.rg.location
30+
failover_priority = 0
31+
}
32+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
output "resource_group_name" {
2+
value = azurerm_resource_group.rg.name
3+
}
4+
5+
output "cosmosdb_account_name" {
6+
value = azurerm_cosmosdb_account.vote_cosmos_db.name
7+
}
8+
9+
output "dns" {
10+
value = azurerm_container_group.vote_aci.fqdn
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
terraform {
2+
required_version = ">=0.12"
3+
4+
required_providers {
5+
azurerm = {
6+
source = "hashicorp/azurerm"
7+
version = "~>2.0"
8+
}
9+
random = {
10+
source = "hashicorp/random"
11+
version = "~>3.0"
12+
}
13+
}
14+
}
15+
16+
provider "azurerm" {
17+
features {}
18+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Azure Cosmos DB in an Azure Container Instance
2+
3+
This template shows how to use Terraform to deploy an Azure Cosmos DB to Azure Container Instances.
4+
5+
## Terraform resource types
6+
7+
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
8+
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
9+
- [random_integer](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/integer)
10+
- [azurerm_cosmosdb_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cosmosdb_account)
11+
12+
## Variables
13+
14+
| Name | Description | Default |
15+
|-|-|-|
16+
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
17+
| `resource_group_location` | Location of the resource group. | eastus |
18+
19+
## Example
20+
21+
To see how to run this example, see [Deploy an Azure Cosmos DB to Azure Container Instances](https://docs.microsoft.com/azure/developer/terraform/deploy-azure-cosmos-db-to-azure-container-instances).
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
variable "resource_group_location" {
2+
default = "eastus"
3+
description = "Location of the resource group."
4+
}
5+
6+
variable "resource_group_name_prefix" {
7+
default = "rg"
8+
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
9+
}

quickstart/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
1717
#### Beginner
1818

1919
- [Azure resource group](./101-resource-group)
20+
- [Azure attestation provider](./101-attestation-provider)
21+
- [Azure Cosmos DB in an Azure Container Instance](./101-cosmos-db-azure-container-instance)
2022
- [Static Website hosted on Azure Storage](./101-storage-static-website)
2123
- [Azure Web App hosting a Linux Container](./101-web-app-linux-container)
2224
- [Azure Web App hosting a Java 8 App on Linux](./101-web-app-linux-java)
@@ -25,6 +27,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
2527
#### Intermediate
2628

2729
- [Azure Web App with ACR](./201-web-app-docker-acr/)
30+
- [Azure Kubernetes Service with Kubernetes cluster](./201-k8s-cluster-with-tf-and-aks)
2831
- [Azure Kubernetes Service with an Admin Dashboard](./201-aks-rbac-dashboard-admin/)
2932
- [Azure Kubernetes Service with Log Analytics](./201-aks-log-analytics/)
3033
- [Azure Kubernetes Service with Helm](./201-aks-helm/)
@@ -52,4 +55,4 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
5255
- [AppGateway fronted VM Scale Set](./201-vmss-appgw-waf/)
5356
- [Azure Pipeline CI/CD for Terraform](./201-azure-pipelines-ci-cd/)
5457
- [AKS with Windows node pools](./301-aks-windows-nodepool/)
55-
- [Hub and Spoke VNet with VMs](./301-hub-spoke-network-3vm/)
58+
- [Hub and Spoke VNet with VMs](./301-hub-spoke-network-3vm/)

0 commit comments

Comments
 (0)