Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions sdk/sql/azure-resourcemanager-sql/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added

- Supported `withAzureActiveDirectoryOnlyAuthentication` and `withExternalActiveDirectoryAdministrator` for `SqlServer`.
- Supported `withManagedIdentity` for `SqlDatabase` import and export.

### Breaking Changes

### Bugs Fixed
Expand Down Expand Up @@ -363,21 +366,21 @@

### Breaking Changes

- Removed `NEW` from `SecurityAlertPolicyState`. The constant is non-functional.
- Removed `NEW` from `SecurityAlertPolicyState`. The constant is non-functional.
- Removed `withPolicyNew` method from `SqlDatabaseThreatDetectionPolicy` since `NEW` is no longer supported in `SecurityAlertPolicyState`.
- Removed `nextResetTime` and `resourceName` methods from `ServerMetric` and `SqlDatabase`. The methods are non-functional.
- Removed `listMetricsDefinitions` and `listMetrics` methods from `SqlDatabase`. Metrics in SQL have been replaced by the Azure monitor shoebox metrics API. Not in SQL any more.
- Removed `listServiceTierAdvisors` method from `SqlDatabase`. It's no longer supported.
- Removed class `ElasticPoolDatabaseActivity`. It's removed from service definition.
- Removed `listDatabaseActivities`, `listDatabaseMetricDefinitions` and `listDatabaseMetrics` methods from `SqlElasticPool`.
- Removed `elasticPoolName` and `serviceLevelObjective` methods from `SqlRestorableDroppedDatabase`.
- Removed `listDatabaseActivities`, `listDatabaseMetricDefinitions` and `listDatabaseMetrics` methods from `SqlElasticPool`.
- Removed `elasticPoolName` and `serviceLevelObjective` methods from `SqlRestorableDroppedDatabase`.
- Removed `getServiceObjective`, `listRecommendedElasticPools`, `listServiceObjectives` methods from `SqlServer`.
- Removed `withCreationDate` and `withThumbprint` from SqlServerKeyOperations. The properties are no longer mutable.
- Renamed class from `TransparentDataEncryptionInner` to `LogicalDatabaseTransparentDataEncryptionInner`.
- Removed class `TransparentDataEncryptionActivity`. The class is no longer functional.
- Removed `listActivities` from `TransparentDataEncryption` since `TransparentDataEncryptionActivity` is removed.
- Renamed `TransparentDataEncryptionStatus` to `TransparentDataEncryptionState`.
- Removed `location`, `requestedDatabaseDtuCap`, `requestedDatabaseDtuGuarantee`, `requestedDatabaseDtuMax`, `requestedDatabaseDtuMin`,
- Removed `location`, `requestedDatabaseDtuCap`, `requestedDatabaseDtuGuarantee`, `requestedDatabaseDtuMax`, `requestedDatabaseDtuMin`,
`requestedDtu`, `requestedDtuGuarantee` and `requestedElasticPoolName`, `requestedStorageLimitInGB` and `requestedStorageLimitInMB` methods from `ElasticPoolActivity`. The properties are no longer functional.
- Renamed class from `ElasticPoolActivityInner` to `ElasticPoolOperationInner`.
- Removed `readReplicaCount` and `withReadReplicaCount` from `DatabaseUpdate`. The property is non-functional.
Expand Down
2 changes: 1 addition & 1 deletion sdk/sql/azure-resourcemanager-sql/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/sql/azure-resourcemanager-sql",
"Tag": "java/sql/azure-resourcemanager-sql_2dccdeacd3"
"Tag": "java/sql/azure-resourcemanager-sql_a84e1b066f"
}
15 changes: 15 additions & 0 deletions sdk/sql/azure-resourcemanager-sql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<jacoco.min.branchcoverage>0.10</jacoco.min.branchcoverage>
<!-- Configures the Java 9+ run to perform the required module exports, opens, and reads that are necessary for testing but shouldn't be part of the module-info. -->
<javaModulesSurefireArgLine>
--add-reads com.azure.resourcemanager.sql=com.azure.resourcemanager.authorization
--add-reads com.azure.resourcemanager.sql=com.azure.resourcemanager.msi

--add-opens com.azure.resourcemanager.sql/com.azure.resourcemanager.sql=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
Expand Down Expand Up @@ -70,6 +73,18 @@
<artifactId>azure-resourcemanager-storage</artifactId>
<version>2.55.5</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-storage;dependency} -->
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-msi</artifactId>
<version>2.53.8</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-msi;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-authorization</artifactId>
<version>2.53.9</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-authorization;dependency} -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
package com.azure.resourcemanager.sql.implementation;

import com.azure.core.management.exception.ManagementException;
import com.azure.core.util.CoreUtils;
import com.azure.resourcemanager.resources.fluentcore.dag.FunctionalTaskItem;
import com.azure.resourcemanager.resources.fluentcore.model.Creatable;
import com.azure.resourcemanager.resources.fluentcore.model.Indexable;
Expand Down Expand Up @@ -66,26 +67,37 @@ public SqlDatabaseExportRequestImpl exportTo(String storageUri) {
private Mono<Indexable> getOrCreateStorageAccountContainer(final StorageAccount storageAccount,
final String containerName, final String fileName, final FunctionalTaskItem.Context context) {
final SqlDatabaseExportRequestImpl self = this;
self.inner.withStorageUri(
String.format("%s%s/%s", storageAccount.endPoints().primary().blob(), containerName, fileName));
BlobContainers blobContainers = this.sqlServerManager.storageManager().blobContainers();
Mono<Indexable> container
= blobContainers.getAsync(parent().resourceGroupName(), storageAccount.name(), containerName)
.map(blobContainer -> (Indexable) blobContainer)
.onErrorResume(error -> {
if (error instanceof ManagementException) {
if (((ManagementException) error).getResponse().getStatusCode() == 404) {
return blobContainers.defineContainer(containerName)
.withExistingStorageAccount(parent().resourceGroupName(), storageAccount.name())
.withPublicAccess(PublicAccess.NONE)
.createAsync()
.map(blobContainer -> (Indexable) blobContainer);
}
}
return Mono.error(error);
});

if (!storageAccount.isSharedKeyAccessAllowed()
// self.inner.storageKey could be set before, e.g. with managed identity ID
|| !CoreUtils.isNullOrEmpty(self.inner.storageKey())) {
return container;
}

return storageAccount.getKeysAsync()
.flatMap(storageAccountKeys -> Mono.justOrEmpty(storageAccountKeys.stream().findFirst()))
.flatMap(storageAccountKey -> {
self.inner.withStorageUri(
String.format("%s%s/%s", storageAccount.endPoints().primary().blob(), containerName, fileName));
self.inner.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY);
self.inner.withStorageKey(storageAccountKey.value());
BlobContainers blobContainers = this.sqlServerManager.storageManager().blobContainers();
return blobContainers.getAsync(parent().resourceGroupName(), storageAccount.name(), containerName)
.onErrorResume(error -> {
if (error instanceof ManagementException) {
if (((ManagementException) error).getResponse().getStatusCode() == 404) {
return blobContainers.defineContainer(containerName)
.withExistingStorageAccount(parent().resourceGroupName(), storageAccount.name())
.withPublicAccess(PublicAccess.NONE)
.createAsync();
}
}
return Mono.error(error);
});
return container;
});
}

Expand Down Expand Up @@ -158,6 +170,20 @@ public SqlDatabaseExportRequestImpl withActiveDirectoryLoginAndPassword(String a
return this.withLoginAndPassword(administratorLogin, administratorPassword);
}

@Override
public SqlDatabaseExportRequestImpl withManagedIdentity(String managedIdentityResourceId) {
Objects.requireNonNull(managedIdentityResourceId);
this.inner.withAuthenticationType(AuthenticationType.MANAGED_IDENTITY.toString());
this.inner.withAdministratorLogin(managedIdentityResourceId);
// No administrator password is required for managed identity authentication.
this.inner.withAdministratorLoginPassword(null);

// Use the same MI for storage account access.
this.inner.withStorageKeyType(StorageKeyType.MANAGED_IDENTITY);
this.inner.withStorageKey(managedIdentityResourceId);
return this;
}

SqlDatabaseExportRequestImpl withLoginAndPassword(String administratorLogin, String administratorPassword) {
this.inner.withAdministratorLogin(administratorLogin);
this.inner.withAdministratorLoginPassword(administratorPassword);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ public SqlDatabaseForElasticPoolImpl withActiveDirectoryLoginAndPassword(String
return this;
}

@Override
public SqlDatabaseForElasticPoolImpl withManagedIdentity(String managedIdentityResourceId) {
this.sqlDatabase.withManagedIdentity(managedIdentityResourceId);
return this;
}

@Override
public SqlDatabaseForElasticPoolImpl fromRestorePoint(RestorePoint restorePoint) {
this.sqlDatabase.fromRestorePoint(restorePoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.management.Region;
import com.azure.core.util.CoreUtils;
import com.azure.resourcemanager.resources.fluentcore.arm.ResourceId;
import com.azure.resourcemanager.resources.fluentcore.arm.ResourceUtils;
import com.azure.resourcemanager.resources.fluentcore.arm.models.implementation.ExternalChildResourceImpl;
Expand Down Expand Up @@ -717,8 +718,11 @@ public SqlDatabaseImpl importFrom(final StorageAccount storageAccount, final Str
.flatMap(storageAccountKey -> {
self.importRequestInner.withStorageUri(
String.format("%s%s/%s", storageAccount.endPoints().primary().blob(), containerName, fileName));
self.importRequestInner.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY);
self.importRequestInner.withStorageKey(storageAccountKey.value());
if (storageAccount.isSharedKeyAccessAllowed()
&& CoreUtils.isNullOrEmpty(self.importRequestInner.storageKey())) {
self.importRequestInner.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY);
self.importRequestInner.withStorageKey(storageAccountKey.value());
}
return context.voidMono();
}));
return this;
Expand Down Expand Up @@ -756,6 +760,20 @@ public SqlDatabaseImpl withActiveDirectoryLoginAndPassword(String administratorL
return this;
}

@Override
public SqlDatabaseImpl withManagedIdentity(String managedIdentityResourceId) {
Objects.requireNonNull(managedIdentityResourceId);
this.importRequestInner.withAuthenticationType(AuthenticationType.MANAGED_IDENTITY.toString());
this.importRequestInner.withAdministratorLogin(managedIdentityResourceId);
// No administrator password is required for managed identity authentication.
this.importRequestInner.withAdministratorLoginPassword(null);

// Use the same MI for storage account access.
this.importRequestInner.withStorageKeyType(StorageKeyType.MANAGED_IDENTITY);
this.importRequestInner.withStorageKey(managedIdentityResourceId);
return this;
}

@Override
public SqlDatabaseImpl fromRestorePoint(RestorePoint restorePoint) {
return fromRestorePoint(restorePoint, restorePoint.earliestRestoreDate());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.
package com.azure.resourcemanager.sql.implementation;

import com.azure.core.util.CoreUtils;
import com.azure.resourcemanager.resources.fluentcore.dag.FunctionalTaskItem;
import com.azure.resourcemanager.resources.fluentcore.model.Indexable;
import com.azure.resourcemanager.resources.fluentcore.model.implementation.ExecutableImpl;
Expand Down Expand Up @@ -55,11 +56,18 @@ public Mono<SqlDatabaseImportExportResponse> executeWorkAsync() {
private Mono<Indexable> getOrCreateStorageAccountContainer(final StorageAccount storageAccount,
final String containerName, final String fileName, final FunctionalTaskItem.Context context) {
final SqlDatabaseImportRequestImpl self = this;
self.inner.withStorageUri(
String.format("%s%s/%s", storageAccount.endPoints().primary().blob(), containerName, fileName));

if (!storageAccount.isSharedKeyAccessAllowed()
// self.inner.storageKey could be set before, e.g. with managed identity ID
|| !CoreUtils.isNullOrEmpty(self.inner.storageKey())) {
return context.voidMono();
}

return storageAccount.getKeysAsync()
.flatMap(storageAccountKeys -> Mono.justOrEmpty(storageAccountKeys.stream().findFirst()))
.flatMap(storageAccountKey -> {
self.inner.withStorageUri(
String.format("%s%s/%s", storageAccount.endPoints().primary().blob(), containerName, fileName));
self.inner.withStorageKeyType(StorageKeyType.STORAGE_ACCESS_KEY);
self.inner.withStorageKey(storageAccountKey.value());
return context.voidMono();
Expand Down Expand Up @@ -117,6 +125,20 @@ public SqlDatabaseImportRequestImpl withActiveDirectoryLoginAndPassword(String a
return this.withLoginAndPassword(administratorLogin, administratorPassword);
}

@Override
public SqlDatabaseImportRequestImpl withManagedIdentity(String managedIdentityResourceId) {
Comment thread
XiaofeiCao marked this conversation as resolved.
Objects.requireNonNull(managedIdentityResourceId);
this.inner.withAuthenticationType(AuthenticationType.MANAGED_IDENTITY.toString());
this.inner.withAdministratorLogin(managedIdentityResourceId);
// No administrator password is required for managed identity authentication.
this.inner.withAdministratorLoginPassword(null);

// Use the same MI for storage account access.
this.inner.withStorageKeyType(StorageKeyType.MANAGED_IDENTITY);
this.inner.withStorageKey(managedIdentityResourceId);
return this;
}

SqlDatabaseImportRequestImpl withLoginAndPassword(String administratorLogin, String administratorPassword) {
this.inner.withAdministratorLogin(administratorLogin);
this.inner.withAdministratorLoginPassword(administratorPassword);
Expand Down
Loading