azure.cosmosdb-collection

CosmosDB Collection Resource

example:

This policy will find all collections with Offer Throughput > 100

policies:
  - name: cosmosdb-high-throughput
    resource: azure.cosmosdb-collection
    filters:
      - type: offer
        key: content.offerThroughput
        op: gt
        value: 100

Filters

Actions

replace-offer

CosmosDB Replace Offer Action

Modify the throughput of a cosmodb collection’s offer

example:

This policy will ensure that no collections have offers with more than 400 RU/s throughput.

policies:
  - name: limit-throughput-to-400
    resource: azure.cosmosdb-collection
    filters:
      - type: offer
        key: content.offerThroughput
        op: gt
        value: 400
    actions:
      - type: replace-offer
        throughput: 400
properties:
  throughput:
    type: number
  type:
    enum:
    - replace-offer
required:
- throughput
- type

restore-throughput-state

CosmosDB Restore State Action

Restores the throughput of a cosmodb collection’s offer from state stored in a tag on the collections’s parent CosmosDB account.

example:

This policy will restore the state of Cosmos DB collections by retrieving the state from the tag ‘on-hour-state’ from its associated Cosmos DB account.

policies:
  - name: restore-throughput-state
    resource: azure.cosmosdb-collection
    actions:
      - type: restore-throughput-state
        state-tag: on-hour-state
properties:
  state-tag:
    type: string
  type:
    enum:
    - restore-throughput-state
required:
- state-tag
- type

save-throughput-state

CosmosDB Store State Action

Stores the throughput of collections in a tag on the parent Cosmos DB account. With accounts that have many collections, it’s important to filter down which collections to store since there is a tag length limit (approx 16 collections).

example:

This policy saves the throughput of collections with throughput over 400 in a tag called ‘on-hour-state’ on the parent Cosmos DB account.

policies:
  - name: store-on-hours-state
    resource: azure.cosmosdb-collection
    filters:
      - type: offer
        key: content.offerThroughput
        op: gt
        value: 400
    actions:
      - type: save-throughput-state
        state-tag: on-hour-state
properties:
  state-tag:
    type: string
  type:
    enum:
    - save-throughput-state
required:
- state-tag
- type