Skip to content

Repository of Azure Management SDK samples for creating and updating Azure Cosmos DB resources in C#, Python, JavaScript, Java and GO

License

Notifications You must be signed in to change notification settings

AzureCosmosDB/management-sdk-samples

Repository files navigation

Azure Management SDK Samples for Azure Cosmos DB

This repository contains Azure Management SDK samples for Azure Cosmos DB to create and update Azure Cosmos DB resources through its resource provider (control plane). Azure resource providers are used to provision and manage resources in Azure.

The samples can be used to support users who are adopting Microsoft Entra ID and disabling key-based access to their data, and want to manage their Cosmos resources using an SDK rather than using Bicep templates, PowerShell, or Azure CLI.

Resource Operations

These samples demonstrate create or update operations on the following Cosmos DB resources, including:

  • Accounts:
    • Serverless, IP firewall rules, and disabling local auth (key-based data plane access) to force Entra ID for Auth-N and role-based access control (RBAC) for Auth-Z
  • Databases
  • Containers:
    • Hierarchical partition keys, index policies, unique keys, TTL, conflict resolution policies, autoscale throughput
  • Throughput
    • Update autoscale or manual throughput
  • RBAC definitions:
    • Creating a built-in definition, creating a custom RBAC definition
  • RBAC assignments

The samples also include some other handy conveniences for developers working with Cosmos resources including:

  • Getting your IP address to add to a Firewall Rule, add Portal Access and Azure data center access
  • Getting your principal id for RBAC assignments

Languages available

The samples are available in 5 languages including:

VS Code debugging (recommended)

This repo contains samples in multiple languages/frameworks. Use the *.code-workspace files at the repo root to open and debug a single language sample at a time.

Each workspace file opens only that language's folder (for example, Python.code-workspace opens Python/). This keeps debug configuration, settings, and environment-file handling isolated per sample.

To avoid VS Code debug adapter errors when you don't have every language extension installed, open the workspace file for the language you're working on:

How to open a workspace file

In VS Code:

  1. Use File → Open Workspace from File…
  2. Pick the *.code-workspace file you want (for example, Python.code-workspace).

Then use Run and Debug (or press F5) to start that sample.

Notes:

  • Opening the repo as a normal folder is fine for browsing, but the run/debug configurations are intentionally isolated per language workspace file.
  • If you switch between languages, just open the other workspace file.

Azure Management SDK source code repositories

All Azure Management SDKs are open source. For more information and the source for the underlying Azure Management SDKs, visit their GitHub repositories.

How to file issues and get help

Azure Management SDKs are fully supported by Microsoft. For issues related to them, please open a support ticket. GitHub issues in this repository are not the correct channel for support.

For questions, feature requests or issues related to just the samples themselves, please use GitHub Issues. Please search the existing issues before filing new ones to avoid duplicates.

Contributing

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.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines.

Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

About

Repository of Azure Management SDK samples for creating and updating Azure Cosmos DB resources in C#, Python, JavaScript, Java and GO

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 5