Skip to content

Commit 1b5c2f1

Browse files
committed
VBS enclave demo changes
1 parent 29aa2bb commit 1b5c2f1

File tree

5 files changed

+43
-32
lines changed

5 files changed

+43
-32
lines changed

samples/features/security/always-encrypted-with-secure-enclaves/azure-sql-database-sgx/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ Perform the below steps before each demo presentation.
118118
- `<project name>vault` - a key vault in Azure Key Vault, containing the column master key for Always Encrypted.
119119
- `ContosoHR` - a database.
120120

121-
1. Right-click on the **ContosoHR** database in the resource group and open its **Overview** blade in the new tab. Click on **Compute + storage** under **Settings**. Click **Change configuration**. Note that the database is already configured to use the DC-series hardware configuration that supports confidential computing using secure enclaves. Setting the DC-series hardware configuration for a database is required to use Always Encrypted with secure enclaves in the database. For more information, see [Enable Intel SGX for your Azure SQL Database](https://docs.microsoft.com/azure/azure-sql/database/always-encrypted-enclaves-enable-sgx).
121+
1. Right-click on the **ContosoHR** database in the resource group and open its **Overview** blade in the new tab. Click on **Compute + storage** under **Settings**. Click **Change configuration**. Note that the database is already configured to use the DC-series hardware configuration that supports confidential computing using secure enclaves. Setting the DC-series hardware configuration for a database is required to use Always Encrypted with secure enclaves in the database. For more information, see [Enable Intel SGX for your Azure SQL Database](https://docs.microsoft.com/azure/azure-sql/database/always-encrypted-enclaves-enable-sgx). In the left ribbon, click on **Data Encryption** and click in the blade on **Always Encrypted**. Confirm that the Secure Enclave is enabled and that the enclave type is **Intel Software Guard Extension (Intel SGX)**
122122

123123
![DC-series hardware configuration](./img/portal-dc-series-configuration.png)
124124

samples/features/security/always-encrypted-with-secure-enclaves/azure-sql-database-vbs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ Perform the below steps before each demo presentation.
128128

129129
2. Click on **Access Policies**. You should see two access policy entries: one for your identity and one for the web app's identity. These policies grant you permissions necessary to perform key management operations and they grant the web app permissions required to decrypt column encryption keys, protecting the data.
130130

131+
1. Close the browser tab for the key vault. Right-click on the logical server in your resource group and open its **Overview** blade in a new tab.
132+
1. Click on **SQL Databases** and select **ContosoHR** database.
133+
2. In the left ribbon, click on **Data Encryption** and click in the blade on **Always Encrypted**.
134+
3. Confirm that the Secure Enclave is enabled and that the enclave type is **Virtualization based security (VBS)**
135+
131136
1. Switch to SSMS.
132137
1. In Object Explorer, navigate to the **ContosoHR** database. Then go to **Security** > **Always Encrypted Keys**.
133138
1. Open the **Column Master Keys** and **Column Encryption Keys** folders. You should see the metadata object, named **CMK1**, for the column master key and the metadata object, named **CEK1**, for the column encryption key.

samples/features/security/always-encrypted-with-secure-enclaves/azure-sql-database-vbs/setup/azuredeploy.bicep

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ param userName string
1515
param sqlAdminUserName string
1616

1717
@description('The password of the Azure SQL database server administrator for SQL authentication.')
18+
@secure()
1819
param sqlAdminPassword string
1920

2021
@description('The IP address the user will connect from to the logical server in Azure SQL Database.')
@@ -29,9 +30,9 @@ param location string = resourceGroup().location
2930
////////////////////////////////////////////
3031

3132
// Create the server
32-
var SQLServerName_var = '${projectName}server'
33-
resource Server_Name_resource 'Microsoft.Sql/servers@2022-05-01-preview' = {
34-
name: SQLServerName_var
33+
var SQLServerName = '${projectName}server'
34+
resource Server_Name_resource 'Microsoft.Sql/servers@2023-02-01-preview' = {
35+
name: SQLServerName
3536
location: location
3637
tags: {}
3738
identity: {
@@ -47,58 +48,60 @@ resource Server_Name_resource 'Microsoft.Sql/servers@2022-05-01-preview' = {
4748
}
4849

4950
// Allow Azure services and resources to access this server
50-
resource Server_Name_AllowAllWindowsAzureIps 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = {
51-
name: '${Server_Name_resource.name}/AllowAllWindowsAzureIps'
51+
resource Server_Name_AllowAllWindowsAzureIps 'Microsoft.Sql/servers/firewallRules@2023-02-01-preview' = {
52+
parent: Server_Name_resource
53+
name: 'AllowAllWindowsAzureIps'
5254
properties: {
5355
endIpAddress: '0.0.0.0'
5456
startIpAddress: '0.0.0.0'
5557
}
5658
}
5759

5860
// Allow Client IP to access this server
59-
resource Server_Name_AllowClientIP 'Microsoft.Sql/servers/firewallRules@2022-05-01-preview' = {
60-
name: '${Server_Name_resource.name}/AllowClientIP'
61+
resource Server_Name_AllowClientIP 'Microsoft.Sql/servers/firewallRules@2023-02-01-preview' = {
62+
parent: Server_Name_resource
63+
name: 'AllowClientIP'
6164
properties: {
6265
endIpAddress: clientIP
6366
startIpAddress: clientIP
6467
}
6568
}
6669

6770
// Make the user an Azure AD administrator for the server, so that the user can connect with universal authentication
68-
resource Server_Name_activeDirectory 'Microsoft.Sql/servers/administrators@2022-05-01-preview' = {
69-
name: '${Server_Name_resource.name}/activeDirectory'
71+
resource Server_Name_activeDirectory 'Microsoft.Sql/servers/administrators@2023-02-01-preview' = {
72+
parent: Server_Name_resource
73+
name: 'activeDirectory'
7074
properties: {
7175
administratorType: 'ActiveDirectory'
7276
login: userName
73-
//sid: reference(resourceId('Microsoft.Sql/servers', '${projectName}server'), '2019-06-01-preview', 'Full').identity.principalId
7477
sid: userObjectId
75-
//tenantId: AAD_TenantId //optional
76-
}
78+
}
7779
}
7880

7981
//////////////////////////////////////////////////////////////////////////////
8082
// Create the ContosoHR database using the DC-series hardware configuration //
8183
//////////////////////////////////////////////////////////////////////////////
8284

83-
resource Database_Resource 'Microsoft.Sql/servers/databases@2022-05-01-preview' = {
84-
name: '${Server_Name_resource.name}/ContosoHR'
85+
resource Database_Resource 'Microsoft.Sql/servers/databases@2023-02-01-preview' = {
86+
parent: Server_Name_resource
87+
name: 'ContosoHR'
8588
location: location
8689
tags: {}
8790
sku: {
8891
name: 'GP_Gen5_2'
8992
tier: 'GeneralPurpose'
9093
}
9194
properties: {
92-
//preferredEnclaveType: 'VBS'
95+
preferredEnclaveType: 'VBS'
9396
}
9497
}
9598

9699
///////////////////////////////////
97100
// Configure the web application //
98101
///////////////////////////////////
99-
102+
var sqlServerSuffix = environment().suffixes.sqlServerHostname
100103
// Create an App Service plan
101-
resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-03-01' = {
104+
resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-09-01' = {
102105
name: '${projectName}plan'
103106
location: location
104107
properties: {}
@@ -108,7 +111,7 @@ resource WebAppServicePlan_Resource 'Microsoft.Web/serverfarms@2022-03-01' = {
108111
}
109112

110113
// Create the App Service
111-
resource WebApp_Resource 'Microsoft.Web/sites@2022-03-01' = {
114+
resource WebApp_Resource 'Microsoft.Web/sites@2022-09-01' = {
112115
name: '${projectName}app'
113116
location: location
114117
identity: {
@@ -123,7 +126,7 @@ resource WebApp_Resource 'Microsoft.Web/sites@2022-03-01' = {
123126
name: 'connectionstrings'
124127
properties: {
125128
ContosoHRDatabase: {
126-
value: 'Server=tcp:${Server_Name_resource.name}.database.windows.net;Database=ContosoHR;Column Encryption Setting=Enabled; Attestation Protocol = None; Authentication=Active Directory Managed Identity'
129+
value: 'Server=tcp:${Server_Name_resource.name}${sqlServerSuffix};Database=ContosoHR;Column Encryption Setting=Enabled; Attestation Protocol = None; Authentication=Active Directory Managed Identity'
127130
type: 'SQLAzure'
128131
}
129132
}
@@ -138,8 +141,9 @@ resource WebApp_Resource 'Microsoft.Web/sites@2022-03-01' = {
138141
}
139142

140143
// Deploy the application
141-
resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-03-01' = {
142-
name: '${projectName}app/web'
144+
resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-09-01' = {
145+
parent: WebApp_Resource
146+
name: 'web'
143147
properties: {
144148
repoUrl: 'https://github.com/microsoft/sql-server-samples.git'
145149
branch: 'master'
@@ -155,7 +159,7 @@ resource sourceControl 'Microsoft.Web/sites/sourcecontrols@2022-03-01' = {
155159
//////////////////////////////////////
156160

157161
// Create a key vault and assign key permissions to the user, so that the user can manage the keys
158-
resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2022-07-01' = {
162+
resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2023-02-01' = {
159163
name: '${projectName}vault'
160164
location: location
161165
tags: {}
@@ -188,7 +192,7 @@ resource KeyVault_Resource 'Microsoft.KeyVault/vaults@2022-07-01' = {
188192
}
189193

190194
// Assign key permissions to the web app
191-
resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPolicies@2022-07-01' = {
195+
resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPolicies@2023-02-01' = {
192196
name: any('${KeyVault_Resource.name}/add')
193197
properties: {
194198
accessPolicies: [
@@ -209,8 +213,9 @@ resource KeyVaultWebAppAccessPolicy_Resource 'Microsoft.KeyVault/vaults/accessPo
209213
}
210214

211215
// Create a key
212-
resource Key_Resource 'Microsoft.KeyVault/vaults/keys@2022-07-01' = {
213-
name: '${KeyVault_Resource.name}/CMK'
216+
resource Key_Resource 'Microsoft.KeyVault/vaults/keys@2023-02-01' = {
217+
parent: KeyVault_Resource
218+
name: 'CMK'
214219
tags: {}
215220
properties: {
216221
attributes: {

samples/features/security/always-encrypted-with-secure-enclaves/azure-sql-database-vbs/setup/setup.ps1

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Import-Module "Az" -MinimumVersion "9.3"
2-
Import-Module "SqlServer" -Version "22.0.49-preview"
1+
Import-Module "Az"
2+
Import-Module "SqlServer"
33

44
######################################################################
55
# Prompt the user to enter the values of deployment parameters
@@ -10,9 +10,9 @@ $subscriptionId = Read-Host -Prompt "Enter your subscription id"
1010
$location = Read-Host -Prompt "Enter a region where you want to deploy the demo environment"
1111
$sqlAdminUserName = Read-Host -Prompt "Enter the username of the Azure SQL database server administrator for SQL authentication"
1212
$sqlAdminPasswordSecureString = Read-Host -Prompt "Enter the password of the Azure SQL database server administrator for SQL authentication" -AsSecureString
13-
13+
$Secure_String_Pwd = ConvertTo-SecureString $sqlAdminPasswordSecureString -AsPlainText -Force
1414
$sqlAdminPassword = (New-Object PSCredential "user",$sqlAdminPasswordSecureString).GetNetworkCredential().Password
15-
$clientIP = (Invoke-WebRequest ifconfig.me/ip).Content.Trim()
15+
$clientIP = (Invoke-WebRequest http://ipinfo.io/ip).Content.Trim()
1616
$bicepFile = "azuredeploy.bicep"
1717
$projectName = $projectName.ToLower()
1818

@@ -35,14 +35,15 @@ New-AzResourceGroup -Name $resourceGroupName -Location $location
3535
# Deploy the resources for the demo environment
3636
######################################################################
3737

38+
3839
New-AzResourceGroupDeployment `
3940
-ResourceGroupName $resourceGroupName `
4041
-TemplateFile $bicepFile `
4142
-projectName $projectName `
4243
-userObjectId $userObjectId `
4344
-userName $userName `
4445
-sqlAdminUserName $sqlAdminUserName `
45-
-sqlAdminPassword $sqlAdminPassword `
46+
-sqlAdminPassword $Secure_String_Pwd `
4647
-clientIP $clientIP
4748

4849
######################################################################

samples/features/security/always-encrypted-with-secure-enclaves/source/ContosoHR/ContosoHR.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<PackageReference Include="Azure.Core" Version="1.27.0" />
17+
<PackageReference Include="Azure.Core" Version="1.35.0" />
1818
<PackageReference Include="Azure.Identity" Version="1.6.0" />
1919
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.1" />
2020
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.1" />

0 commit comments

Comments
 (0)