Skip to content

Commit af01177

Browse files
iviarkmarbaker-msmsJinLei
authored
Healthcare APIs Powershell BYOK Updates (#13518)
* Implementing changes for BYOK healthcareapis * Fixing build error in healthcareapis set azure method * Regenerating documentation * Fixing bugs and updating recording file * Healthcareapis * Updating help files * Updating test recording * Removing unused code in test script * Addressing PR comments * Removing trailing " from help file * Fixing build errors and updating test record file * Update ChangeLog.md Co-authored-by: Mark Baker <[email protected]> Co-authored-by: Jin Lei <[email protected]>
1 parent a735ca7 commit af01177

File tree

14 files changed

+1881
-1093
lines changed

14 files changed

+1881
-1093
lines changed

src/HealthcareApis/HealthcareApis.Test/ScenarioTests/Common.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ function Get-OfferThroughput
4848
return 1000
4949
}
5050

51+
<#
52+
.SYNOPSIS
53+
Gets keyVaultKeyUri value
54+
#>
55+
function Get-KeyVaultKeyUri
56+
{
57+
return "https://pshealthapitestvault.vault.azure.net/keys/PSKey1"
58+
}
59+
5160
<#
5261
.SYNOPSIS
5362
Gets kind value

src/HealthcareApis/HealthcareApis.Test/ScenarioTests/HealthcareApisServiceTests.ps1

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function Test-AzRmHealthcareApisService{
2828
$rgname = Get-ResourceGroupName
2929
$rname = Get-ResourceName
3030
$location = Get-Location
31+
$keyVaultKeyUri = Get-KeyVaultKeyUri
3132
$offerThroughput = Get-OfferThroughput
3233
$kind = Get-Kind
3334
$object_id = Get-AccessPolicyObjectID;
@@ -40,12 +41,13 @@ function Test-AzRmHealthcareApisService{
4041
New-AzResourceGroup -Name $rgname -Location $location
4142

4243
# Create App
43-
$created = New-AzHealthcareApisService -Name $rname -ResourceGroupName $rgname -Location $location -Kind $kind -CosmosOfferThroughput $offerThroughput -ManagedIdentity -ExportStorageAccountName $storageAccountName;
44+
$created = New-AzHealthcareApisService -Name $rname -ResourceGroupName $rgname -Location $location -Kind $kind -CosmosKeyVaultKeyUri $keyVaultKeyUri -CosmosOfferThroughput $offerThroughput -ManagedIdentity -ExportStorageAccountName $storageAccountName;
4445

4546
$actual = Get-AzHealthcareApisService -ResourceGroupName $rgname -Name $rname
4647

4748
# Assert
4849
Assert-AreEqual $rname $actual.Name
50+
Assert-AreEqual $keyVaultKeyUri $actual.CosmosDbKeyVaultKeyUri
4951
Assert-AreEqual $offerThroughput $actual.CosmosDbOfferThroughput
5052
Assert-AreEqual $kind $actual.Kind
5153
Assert-AreEqual "https://$rname.azurehealthcareapis.com" $actual.Audience
@@ -55,13 +57,15 @@ function Test-AzRmHealthcareApisService{
5557
Assert-NotNull $actual.IdentityTenantId
5658

5759
#Update using parameters
58-
$newOfferThroughput = $offerThroughput - 600
59-
$updated = Set-AzHealthcareApisService -ResourceId $actual.Id -CosmosOfferThroughput $newOfferThroughput -DisableManagedIdentity;
60+
$newKeyVaultKeyUri = "https://pshealthapitestvault.vault.azure.net/keys/PSKey2"
61+
$newOfferThroughput = 400
62+
$updated = Set-AzHealthcareApisService -ResourceId $actual.Id -CosmosKeyVaultKeyUri $newKeyVaultKeyUri -CosmosOfferThroughput $newOfferThroughput -DisableManagedIdentity;
6063

6164
$updatedAccount = Get-AzHealthcareApisService -ResourceGroupName $rgname -Name $rname
6265

6366
# Assert the update
6467
Assert-AreEqual $rname $updatedAccount.Name
68+
Assert-AreEqual $newKeyVaultKeyUri $updatedAccount.CosmosDbKeyVaultKeyUri
6569
Assert-AreEqual $newOfferThroughput $updatedAccount.CosmosDbOfferThroughput
6670
Assert-AreEqual "None" $updatedAccount.IdentityType
6771

src/HealthcareApis/HealthcareApis.Test/SessionRecords/Microsoft.Azure.Commands.HealthcareApisService.Test.ScenarioTests.HealthcareApisServiceTests/TestAzRmHealthcareApisService.json

Lines changed: 1552 additions & 994 deletions
Large diffs are not rendered by default.

src/HealthcareApis/HealthcareApis/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added support for customer managed keys
2122

2223
## Version 3.0.0
2324
* Updated the SDK version to 3.0.0

src/HealthcareApis/HealthcareApis/HealthcareApis/NewAzureRmHealthcareApisService.cs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using System.Collections.Generic;
16-
using System.Management.Automation;
17-
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
18-
using System.Collections;
19-
using Microsoft.Azure.Management.HealthcareApis.Models;
20-
using Microsoft.Azure.Management.HealthcareApis;
21-
using Microsoft.Azure.Commands.HealthcareApis.Models;
2215
using Microsoft.Azure.Commands.HealthcareApis.Common;
23-
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
16+
using Microsoft.Azure.Commands.HealthcareApis.Models;
2417
using Microsoft.Azure.Commands.HealthcareApis.Properties;
25-
using System;
18+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
19+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
20+
using Microsoft.Azure.Management.HealthcareApis;
21+
using Microsoft.Azure.Management.HealthcareApis.Models;
2622
using Microsoft.Azure.PowerShell.Cmdlets.HealthcareApis.Common;
23+
using System;
24+
using System.Collections;
25+
using System.Collections.Generic;
26+
using System.Management.Automation;
2727

2828
namespace Microsoft.Azure.Commands.HealthcareApis.Commands
2929
{
@@ -114,6 +114,12 @@ public class NewAzureRmHealthcareApisService : HealthcareApisBaseCmdlet
114114
[ValidateNotNullOrEmpty]
115115
public string[] CorsOrigin { get; set; }
116116

117+
[Parameter(
118+
Mandatory = false,
119+
HelpMessage = "HealthcareApis Fhir Service CosmosKeyVaultKeyUri. The URI of the customer-managed key for the backing database.")]
120+
[ValidateNotNullOrEmpty]
121+
public string CosmosKeyVaultKeyUri { get; set; }
122+
117123
[Parameter(
118124
Mandatory = false,
119125
HelpMessage = "HealthcareApis Fhir Service CosmosOfferThroughput.")]
@@ -180,16 +186,16 @@ public override void ExecuteCmdlet()
180186
Properties = new ServicesProperties()
181187
{
182188
AuthenticationConfiguration = new ServiceAuthenticationConfigurationInfo() { Authority = GetAuthority(), Audience = GetAudience(), SmartProxyEnabled = EnableSmartProxy.ToBool() },
183-
CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo() { OfferThroughput = GetCosmosDBThroughput() },
189+
CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo() { OfferThroughput = GetCosmosDBThroughput(), KeyVaultKeyUri = GetCosmosDBKeyVaultKeyUri() },
184190
CorsConfiguration = new ServiceCorsConfigurationInfo() { Origins = CorsOrigin, Headers = CorsHeader, Methods = CorsMethod, MaxAge = CorsMaxAge, AllowCredentials = AllowCorsCredential },
185-
ExportConfiguration = new ServiceExportConfigurationInfo() { StorageAccountName = ExportStorageAccountName},
191+
ExportConfiguration = new ServiceExportConfigurationInfo() { StorageAccountName = ExportStorageAccountName },
186192
AccessPolicies = accessPolicies,
187193
}
188194
};
189-
195+
190196
if (this.ManagedIdentity.IsPresent)
191197
{
192-
servicesDescription.Identity = new Management.HealthcareApis.Models.ServicesResourceIdentity() { Type = "SystemAssigned" };
198+
servicesDescription.Identity = new ServicesResourceIdentity() { Type = "SystemAssigned" };
193199
}
194200

195201
if (!string.IsNullOrEmpty(PublicNetworkAccess))
@@ -288,6 +294,11 @@ private Kind ParseKindFromVersion(string fhirVersion)
288294
return CosmosOfferThroughput;
289295
}
290296

297+
private string GetCosmosDBKeyVaultKeyUri()
298+
{
299+
return CosmosKeyVaultKeyUri;
300+
}
301+
291302
private string GetAudience()
292303
{
293304
if (string.IsNullOrEmpty(this.Audience))

src/HealthcareApis/HealthcareApis/HealthcareApis/RemoveAzureRmHealthcareApisService.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Microsoft.Azure.Commands.HealthcareApis.Properties;
1615
using Microsoft.Azure.Commands.HealthcareApis.Common;
1716
using Microsoft.Azure.Commands.HealthcareApis.Models;
18-
using Microsoft.Azure.Management.HealthcareApis;
19-
using System.Globalization;
20-
using System.Management.Automation;
17+
using Microsoft.Azure.Commands.HealthcareApis.Properties;
2118
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
19+
using Microsoft.Azure.Management.HealthcareApis;
2220
using Microsoft.Azure.Management.HealthcareApis.Models;
2321
using System;
2422
using System.Collections.Generic;
23+
using System.Globalization;
24+
using System.Management.Automation;
2525

2626
namespace Microsoft.Azure.Commands.HealthcareApis.Commands
2727
{

0 commit comments

Comments
 (0)