
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
github.com/azure-samples/cosmosdb-go-mongodb-quickstart
page_type: sample languages:
The sample application is a command-line based todo
management tool written in Go. Azure Cosmos DB's API for MongoDB is compatible with the MongoDB wire protocol, making it possible for any MongoDB client driver to connect to it. This application uses the Go driver for MongoDB in a way that is transparent to the application that the data is stored in an Azure Cosmos DB database.
.mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true
.Clone the application
git clone https://github.com/Azure-Samples/cosmosdb-go-mongodb-quickstart
Change into the directory where you cloned the application and build it (using go build
).
cd monogdb-go-quickstart
go build -o todo
To confirm that the application was built properly.
./todo --help
To configure the application, export the connection string, MongoDB database and collection names as environment variables.
export MONGODB_CONNECTION_STRING="mongodb://<COSMOSDB_ACCOUNT_NAME>:<COSMOSDB_PASSWORD>@<COSMOSDB_ACCOUNT_NAME>.mongo.cosmos.azure.com:10255/?ssl=true&replicaSet=globaldb&maxIdleTimeMS=120000&appName=@<COSMOSDB_ACCOUNT_NAME>@"
The
ssl=true
option is important because of Cosmos DB requirements. For more information, see Connection string requirements.
For the MONGODB_CONNECTION_STRING
environment variable, replace the placeholders for <COSMOSDB_ACCOUNT_NAME>
and <COSMOSDB_PASSWORD>
<COSMOSDB_ACCOUNT_NAME>
: The name of the Azure Cosmos DB account<COSMOSDB_PASSWORD>
: The Azure Cosmos DB database keyexport MONGODB_DATABASE=todo-db
export MONGODB_COLLECTION=todos
You can choose your preferred values for MONGODB_DATABASE
and MONGODB_COLLECTION
or leave them as is.
To create a todo
./todo --create "Create an Azure Cosmos DB database account"
If successful, you should see an output with the MongoDB _id
of the newly created document:
added todo ObjectID("5e9fd6befd2f076d1f03bd8a")
Create another todo
./todo --create "Get the MongoDB connection string using the Azure CLI"
List all the todo
s
./todo --list all
You should see the ones you just added in a tabular format as such
+----------------------------+--------------------------------+-----------+
| ID | DESCRIPTION | STATUS |
+----------------------------+--------------------------------+-----------+
| "5e9fd6b1bcd2fa6bd267d4c4" | Create an Azure Cosmos DB | pending |
| | database account | |
| "5e9fd6befd2f076d1f03bd8a" | Get the MongoDB connection | pending |
| | string using the Azure CLI | |
+----------------------------+--------------------------------+-----------+
To update the status of a todo
(e.g. change it to completed
status), use the todo
ID
./todo --update 5e9fd6b1bcd2fa6bd267d4c4,completed
List only the completed todo
s
./todo --list completed
You should see the one you just updated
+----------------------------+--------------------------------+-----------+
| ID | DESCRIPTION | STATUS |
+----------------------------+--------------------------------+-----------+
| "5e9fd6b1bcd2fa6bd267d4c4" | Create an Azure Cosmos DB | completed |
| | database account | |
+----------------------------+--------------------------------+-----------+
Delete a todo
using it's ID
./todo --delete 5e9fd6b1bcd2fa6bd267d4c4,completed
List the todo
s to confirm
./todo --list all
The todo
you just deleted should not be present
+----------------------------+--------------------------------+-----------+
| ID | DESCRIPTION | STATUS |
+----------------------------+--------------------------------+-----------+
| "5e9fd6befd2f076d1f03bd8a" | Get the MongoDB connection | pending |
| | string using the Azure CLI | |
+----------------------------+--------------------------------+-----------+
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.