Mongo DB Resources - Create Update Mongo User Definition
Creates or updates an Azure Cosmos DB Mongo User Definition.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DocumentDB/databaseAccounts/{accountName}/mongodbUserDefinitions/{mongoUserDefinitionId}?api-version=2024-11-15
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
account
|
path | True |
string minLength: 3maxLength: 50 pattern: ^[a-z0-9]+(-[a-z0-9]+)* |
Cosmos DB database account name. |
mongo
|
path | True |
string |
The ID for the User Definition {dbName.userName}. |
resource
|
path | True |
string minLength: 1maxLength: 90 |
The name of the resource group. The name is case insensitive. |
subscription
|
path | True |
string minLength: 1 |
The ID of the target subscription. |
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
Request Body
Name | Type | Description |
---|---|---|
createUpdateMongoUserDefinitionParameters |
The properties required to create or update a User Definition. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
The User Definition create or update operation was completed successfully. |
|
202 Accepted |
The User Definition create or update request was accepted and will complete asynchronously. |
|
Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
Name | Description |
---|---|
user_impersonation | Impersonate your user account |
Examples
CosmosDBMongoDBUserDefinitionCreateUpdate
Sample request
PUT https://management.azure.com/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/mongodbUserDefinitions/myMongoUserDefinitionId?api-version=2024-11-15
{
"properties": {
"userName": "myUserName",
"password": "myPassword",
"databaseName": "sales",
"customData": "My custom data",
"roles": [
{
"role": "myReadRole",
"db": "sales"
}
],
"mechanisms": "SCRAM-SHA-256"
}
}
Sample response
{
"id": "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/mongodbUserDefinitions/myUserId",
"name": "myUserName",
"type": "Microsoft.DocumentDB/databaseAccounts/mongodbUserDefinitions",
"properties": {
"userName": "myUserName",
"databaseName": "sales",
"customData": "My custom data",
"roles": [
{
"db": "sales",
"role": "myReadRole"
}
],
"mechanisms": "SCRAM-SHA-256"
}
}
Definitions
Name | Description |
---|---|
Cloud |
An error response from the service. |
Error |
Error Response. |
Mongo |
The properties required to create or update a User Definition. |
Mongo |
An Azure Cosmos DB User Definition |
Role |
The set of roles inherited by the User Definition. |
CloudError
An error response from the service.
Name | Type | Description |
---|---|---|
error |
Error Response. |
ErrorResponse
Error Response.
Name | Type | Description |
---|---|---|
code |
string |
Error code. |
message |
string |
Error message indicating why the operation failed. |
MongoUserDefinitionCreateUpdateParameters
The properties required to create or update a User Definition.
Name | Type | Description |
---|---|---|
properties.customData |
string |
A custom definition for the USer Definition. |
properties.databaseName |
string |
The database name for which access is being granted for this User Definition. |
properties.mechanisms |
string |
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256. |
properties.password |
string |
The password for User Definition. Response does not contain user password. |
properties.roles |
Role[] |
The set of roles inherited by the User Definition. |
properties.userName |
string |
The user name for User Definition. |
MongoUserDefinitionGetResults
An Azure Cosmos DB User Definition
Name | Type | Description |
---|---|---|
id |
string |
The unique resource identifier of the database account. |
name |
string |
The name of the database account. |
properties.customData |
string |
A custom definition for the USer Definition. |
properties.databaseName |
string |
The database name for which access is being granted for this User Definition. |
properties.mechanisms |
string |
The Mongo Auth mechanism. For now, we only support auth mechanism SCRAM-SHA-256. |
properties.password |
string |
The password for User Definition. Response does not contain user password. |
properties.roles |
Role[] |
The set of roles inherited by the User Definition. |
properties.userName |
string |
The user name for User Definition. |
type |
string |
The type of Azure resource. |
Role
The set of roles inherited by the User Definition.
Name | Type | Description |
---|---|---|
db |
string |
The database name the role is applied. |
role |
string |
The role name. |