The Simplest Way to Make Cloud Foundry and Cosmosdb Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams use cloud foundry and cosmosdb together to run cloud apps with fast data storage. Cloud Foundry runs your app code while CosmosDB stores and scales your document data. This pair helps teams push code fast and scale data across many regions. Still, linking the app runtime to the cloud database takes careful setup. You must manage how apps log in and how engineers check live data. How cloud foundry and cosmosdb share keys and data Cloud Foundry runs apps inside isolated spaces and binds

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Teams use cloud foundry and cosmosdb together to run cloud apps with fast data storage. Cloud Foundry runs your app code while CosmosDB stores and scales your document data.

This pair helps teams push code fast and scale data across many regions. Still, linking the app runtime to the cloud database takes careful setup. You must manage how apps log in and how engineers check live data.

How cloud foundry and cosmosdb share keys and data

Cloud Foundry runs apps inside isolated spaces and binds them to external data services. When an app starts, the platform passes database keys through environment variables. The app reads those variables to open a link to the CosmosDB account.

You can set up this link with a service broker or user-provided service instances. A service broker creates the database account and binds the keys to your app. User-provided services let you paste existing CosmosDB keys into the Cloud Foundry space.

Once linked, the app sends read and write requests over the network to CosmosDB. Identity checks happen through master keys, resource tokens, or cloud directory identities. Picking the right login method keeps your data safe and easy to manage.

Common failure modes with shared keys and broad roles

Many teams bind the primary CosmosDB master key straight to their Cloud Foundry apps. That key gives full control over every container and item in the database account. If one app leaks its environment variables, an attacker gains full database control.

Shared service accounts also create blind spots during live incident checks. Developers with space developer roles can read bound app variables in Cloud Foundry. They often copy those shared keys to run manual queries from their own laptops.

CosmosDB RBAC + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

When five engineers use the same app key, audit logs cannot show who ran a query. You cannot tell if a delete command came from the app or a person. Unlogged queries make security reviews slow and risky for the whole team.

How to scope roles and network paths

Start by replacing master keys with scoped role assignments for every single app. Give each Cloud Foundry app a distinct identity that only reads its own container. If an app only reads data, assign a read-only role in the database.

Next, lock down the network path between your app runtime and the data store. Set up private endpoints or firewall rules so CosmosDB only accepts traffic from known subnets. Block public internet traffic when your team does not need it for outside tools.

You should also separate app traffic from human debug work at all times. Never let engineers pull bound keys from Cloud Foundry to check live production data. Give engineers their own login path that records every query and masks sensitive fields.

Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. This keeps private user details safe while engineers fix bugs in production containers. Rotating app keys on a regular schedule also limits the risk of old credentials.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

How do Cloud Foundry apps get CosmosDB keys at startup?

Cloud Foundry injects bound service details into the app through a system environment variable. The app reads this JSON data at startup to find the database URI and key.

Should we use a service broker or user-provided services for CosmosDB?

Use the cloud service broker when you want the platform to create and delete databases. Use a user-provided service when a separate data team manages the CosmosDB account.

How can we stop developers from copying keys out of Cloud Foundry?

Limit who holds the space developer role in your production Cloud Foundry spaces. Give engineers a separate, audited login tool for database checks instead of raw space roles.

The query runs. The emails stay hidden.