I am trying to access cosmosdb data using Spring boot using the article – Microsoft CosmosDB API
and getting error.
The Stacktrace – core – does not have required RBAC permissions to perform action [Microsoft.DocumentDB/databaseAccounts/readMetadata] on resource
com.azure.cosmos.CosmosException: {"innerErrorMessage":"Request blocked by Auth MASKED : Request is blocked because principal [ MA-SK-ED] does not have required RBAC permissions to perform action [Microsoft.DocumentDB/databaseAccounts/readMetadata] on resource [/]. Learn more: https://aka.ms/cosmos-native-rbac.rnActivityId: MA-SK-ED, Microsoft.Azure.Documents.Common/2.14.0, StatusCode: Forbidden","cosmosDiagnostics":artTimeUTC":"2024-05-14T12:34:59.579377200Z","durationInMilliSecs":26.5077},{"eventName":"received","startTimeUTC":"2024-05-14T12:34:59.605884900Z","durationInMilliSecs":15.0303}],"partitionKeyRangeId":null,"responsePayloadSizeInBytes":0,"exceptionMessage":"Request blocked by Auth MASKED : Request is blocked because principal [ MA-SK-ED] does not have required RBAC permissions to perform action [Microsoft.DocumentDB/databaseAccounts/readMetadata] on resource [/]. Learn more: https://aka.ms/cosmos-native-rbac.rnActivityId: MA-SK-ED, Microsoft.Azure.Documents.Common/2.14.0, StatusCode: Forbidden","exceptionResponseHeaders":"{Transfer-Encoding=chunked, Strict-Transport-Security=max-age=31536000, Server=Microsoft-HTTPAPI/2.0, Content-Location=https:// MASKED.documents.azure.com/, x-ms-gatewayversion=version=2.14.0, Date=Tue, 14 May 2024 12:34:59 GMT, x-ms-activity-id= MA-SK-ED, Content-Type=application/json, x-ms-substatus=5301}"}],"samplingRateSnapshot":1.0,"systemInformation":{"usedMemory":"24960 KB","availableMemory":"16694912 KB","systemCpuLoad":"empty","availableProcessors":16},"clientCfgs":{"id":1,"machineId":"uuid: MA-SK-ED_","connectionMode":"DIRECT","numberOfClients":1,"excrgns":"[]","clientEndpoints":{"https:// MASKED.documents.azure.com:443/":1},"connCfg":{"rntbd":null,"gw":"(cps:1000, nrto:PT1M, icto:PT1M, p:false)","other":"(ed: true, cs: false, rv: true)"},"consistencyCfg":"(consistency: null, mm: true, prgns: [])","proactiveInitCfg":"","e2ePolicyCfg":"","sessionRetryCfg":""}}}
at com.azure.cosmos.BridgeInternal.createCosmosException(BridgeInternal.java:478) ~[azure-cosmos-4.58.0.jar:4.58.0]
at com.azure.cosmos.implementation.RxGatewayStoreModel.validateOrThrow(RxGatewayStoreModel.java:504) ~[azure-cosmos-4.58.0.jar:4.58.0]
at com.azure.cosmos.implementation.RxGatewayStoreModel.lambda$toDocumentServiceResponse$1(RxGatewayStoreModel.java:365) ~[azure-cosmos-4.58.0.jar:4.58.0]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.109.Final.jar:4.1.109.Final]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.109.Final.jar:4.1.109.Final]
at java.base/java.lang.Thread.run(Thread.java:833) ~[na:na]
POM
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>cosmosdb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cosmosdb</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>17</java.version>
<spring-cloud-azure.version>5.12.0</spring-cloud-azure.version>
</properties>
<dependencies>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-starter-data-cosmos</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>${spring-cloud-azure.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
My application.properties
spring.application.name=cosmosdb
spring.cloud.azure.cosmos.endpoint=https://cosm99995338tw8ter8w67.documents.azure.com:443/
spring.cloud.azure.cosmos.database=cosmosdb000773
spring.cloud.azure.cosmos.populate-query-metrics=true
Entity
@Container(containerName = "samplecontainer")
public class Employee {....}
Repository is normal as in the article
My cosmosdb
I am not sure of the permissions ( not mentioned in the article) , but I see my id is owner (cosmos db account IAM)
What is the problem with the example ?
Thank you