Files
sql-server-samples/samples/manage/azure-sql-db-managed-instance/upload-tde-certificate/README.md
T

2.9 KiB

Upload certificate to Azure SQL Managed Instance using Azure PowerShell

Script that takes path to .cer and .pvk files and uploads them to SQL MI. See more.

Contents

About this sample
Before you begin
Run this sample
Sample details
Disclaimers
Related links

About this sample

  • Applies to: Azure SQL Database
  • Key features: Managed Instance
  • Workload: n/a
  • Programming Language: PowerShell
  • Authors: Srdan Bozovic
  • Update history: n/a

Before you begin

To run this sample, you need the following prerequisites.

Software prerequisites:

  1. Running Microsoft Windows operating system (as script uses PInvoke for crypto api)
  2. PowerShell 5.0 or higher installed
  3. AzureRM.Sql module version 4.10.0 or higher

Azure prerequisites:

  1. Permission to manage Azure SQL Managed Instance

Run this sample

Run the script below from either Windows or Azure Cloud Shell


$scriptUrlBase = 'https://raw.githubusercontent.com/Microsoft/sql-server-samples/master/samples/manage/azure-sql-db-managed-instance/upload-tde-certificate'

$parameters = @{
    subscriptionId = '<subscriptionId>'
    resourceGroupName = '<resourceGroupName>'
    managedInstanceName  = '<managedInstanceName>'
    publicKeyFile  = '<publicKeyFile>'
    privateKeyFile  = '<privateKeyFile>'
    password  = '<password>'
    }

Invoke-Command -ScriptBlock ([Scriptblock]::Create((iwr ($scriptUrlBase+'/uploadTDECertificate.ps1?t='+ [DateTime]::Now.Ticks)).Content)) -ArgumentList $parameters

Sample details

This sample shows how to convert .cer and .pvk files to base64 .pfx blob and upload it to SQL MI using PowerShell.

Disclaimers

The scripts and this guide are copyright Microsoft Corporations and are provided as samples. They are not part of any Azure service and are not covered by any SLA or other Azure-related agreements. They are provided as-is with no warranties express or implied. Microsoft takes no responsibility for the use of the scripts or the accuracy of this document. Familiarize yourself with the scripts before using them.

For more information, see these articles: