Skip to content

Commit e99578d

Browse files
mgmt, update readme to include trouble shooting on dependencies (Azure#20215)
* add rbac link * mgmt, update readme about dependency management
1 parent 909ec4d commit e99578d

File tree

1 file changed

+77
-2
lines changed

1 file changed

+77
-2
lines changed

sdk/resourcemanager/README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ The services available via `azure-resourcemanager` are listed as below:
7070
- SQL
7171
- Storage
7272
- Traffic Manager
73-
- Search (preview)
73+
- Search
7474
</details>
7575

7676
In the case where you are interested in certain service above or the service not included in the multi-service package, you can choose to use the single-service package for each service. Those packages follow the same naming patterns and design principals. For example, the package for Media Services has the following artifact information.
@@ -157,7 +157,7 @@ The key concepts of Azure Management Libraries includes:
157157
- Fluent interface to manage Azure resources.
158158
- Dependency across Azure resources.
159159
- Batch Azure resource provisioning.
160-
- Integration with Azure role-based access control.
160+
- Integration with [Azure role-based access control][rbac].
161161
- Asynchronous operations with [Reactor][reactor]. (Preview)
162162
- Configurable client, e.g. configuring HTTP client, retries, logging, etc.
163163
- [API design][design]
@@ -355,6 +355,80 @@ AzureResourceManager azure = AzureResourceManager
355355
.withDefaultSubscription();
356356
```
357357

358+
### Dependency management
359+
360+
[Azure Core][azure_core] (`azure-core`) is the shared library for all packages under `com.azure`.
361+
It guarantees backward compatibility.
362+
363+
However, if one accidentally uses an older version of it via transitive dependencies, it might cause problem in runtime.
364+
This case could happen when one module depends on multiple Azure Java SDKs with different versions, which in turn depends on different versions of `azure-core`.
365+
366+
Maven dependency plugin would help to diagnostic this problem.
367+
Here is an artificial example.
368+
369+
```shell
370+
mvn dependency:tree -Dincludes=com.azure:azure-core
371+
372+
[INFO] com.microsoft.azure:azure-sdk-test:jar:1.0-SNAPSHOT
373+
[INFO] \- com.azure:azure-identity:jar:1.2.2:compile
374+
[INFO] \- com.azure:azure-core:jar:1.12.0:compile
375+
```
376+
377+
We can see the `azure-core` resolved as 1.12.0.
378+
379+
```shell
380+
mvn dependency:tree -Dverbose=true -Dincludes=com.azure:azure-core
381+
382+
[INFO] com.microsoft.azure:azure-sdk-test:jar:1.0-SNAPSHOT
383+
[INFO] +- com.azure:azure-identity:jar:1.2.2:compile
384+
[INFO] | +- com.azure:azure-core:jar:1.12.0:compile
385+
[INFO] | \- com.azure:azure-core-http-netty:jar:1.7.1:compile
386+
[INFO] | \- (com.azure:azure-core:jar:1.12.0:compile - omitted for duplicate)
387+
[INFO] +- com.azure.resourcemanager:azure-resourcemanager:jar:2.2.0:compile
388+
[INFO] | +- com.azure.resourcemanager:azure-resourcemanager-resources:jar:2.2.0:compile
389+
[INFO] | | +- (com.azure:azure-core:jar:1.13.0:compile - omitted for conflict with 1.12.0)
390+
[INFO] | | \- com.azure:azure-core-management:jar:1.1.1:compile
391+
[INFO] | | \- (com.azure:azure-core:jar:1.13.0:compile - omitted for conflict with 1.12.0)
392+
[INFO] | \- com.azure.resourcemanager:azure-resourcemanager-keyvault:jar:2.2.0:compile
393+
[INFO] | +- com.azure:azure-security-keyvault-keys:jar:4.2.5:compile
394+
[INFO] | | \- (com.azure:azure-core:jar:1.13.0:compile - omitted for conflict with 1.12.0)
395+
[INFO] | \- com.azure:azure-security-keyvault-secrets:jar:4.2.5:compile
396+
[INFO] | \- (com.azure:azure-core:jar:1.13.0:compile - omitted for conflict with 1.12.0)
397+
[INFO] \- com.azure:azure-storage-blob:jar:12.10.2:compile
398+
[INFO] +- (com.azure:azure-core:jar:1.12.0:compile - omitted for duplicate)
399+
[INFO] \- com.azure:azure-storage-common:jar:12.10.1:compile
400+
[INFO] \- (com.azure:azure-core:jar:1.12.0:compile - omitted for duplicate)
401+
```
402+
403+
From the module, we can see there is multiple SDKs depends on different versions of `azure-core`, and the latest would be 1.13.0.
404+
405+
If we run the module, we will encounter this error in runtime.
406+
407+
```
408+
java.lang.NoSuchMethodError: 'com.azure.core.http.HttpHeaders com.azure.core.http.HttpHeaders.set(java.lang.String, java.lang.String)'
409+
```
410+
411+
The cause is that this method was not available in 1.12.0 `azure-core`, and now being used by some SDK that depends on 1.13.0 `azure-core`.
412+
413+
In this example, apparently the problem is that we used an old version of `azure-identity`. After upgrade it to 1.2.3, problem solved.
414+
415+
Better, one can explicitly put `azure-core` as the first dependency, and keep it up-to-date.
416+
417+
Alternatively, maven dependency management will also help to control the version in transitive dependencies.
418+
Here is a sample dependency management section in maven POM.
419+
420+
```xml
421+
<dependencyManagement>
422+
<dependencies>
423+
<dependency>
424+
<groupId>com.azure</groupId>
425+
<artifactId>azure-core</artifactId>
426+
<version>${azure-core.version}</version>
427+
</dependency>
428+
</dependencies>
429+
</dependencyManagement>
430+
```
431+
358432
### ARM throttling
359433

360434
Azure Resource Manager applies throttling on the number of requests sent from client within certain span of time.
@@ -388,3 +462,4 @@ For details on contributing to this repository, see the [contributing guide](htt
388462
[design_preview]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/DESIGN_PREVIEW.md
389463
[throttling]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/THROTTLING.md
390464
[reactor]: https://projectreactor.io/
465+
[rbac]: https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/resourcemanager/docs/RBAC.md

0 commit comments

Comments
 (0)