xDB Collectionデータベース シャードの分割またはマージ中にAzure App Serviceで発生した自己署名証明書が作成される問題のトラブルシューティング


説明

xDB Collectionデータベースのシャードを分割したりまたはマージしたりする際、証明書の作成に使用されるPowerShellのコマンドが機能しない場合があります。
本記事では、Microsoft社ドキュメントに記載されているPowerShellを使用して自己署名証明書とPFXファイルを作成する方法に対する、代替のアプローチを説明します。

対策

ウェブ アプリケーション専用の自己署名証明書およびPFXファイルを作成するには、以下のスクリプトをPowerShellで実行してください(※スクリプト中の「*.cloudapp.net」は変更しないようご注意ください)。

# パラメータを定義する
$certName = "*.cloudapp.net"
$pfxPath = "{yourpathandname}.pfx"   # Path to store the .pfx file
$cerPath = "{yourpathandname}.cer"   # Path to store the .cer file
$password = "{yourpassword}" # Password to protect the .pfx file                
# Create the self-signed certificate in the "CurrentUser\My" store
$cert = New-SelfSignedCertificate `
    -DnsName $certName `
    -CertStoreLocation "Cert:\CurrentUser\My" `
    -KeySpec KeyExchange `
    -Type Custom `
    -KeyUsage DigitalSignature, KeyEncipherment `
    -TextExtension @("2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2") `
    -HashAlgorithm "SHA256" `
    -KeyLength 2048

# 証明書を.pfxファイル(秘密鍵あり) にエクスポートする
Export-PfxCertificate `
    -Cert $cert `
    -FilePath $pfxPath `
    -Password (ConvertTo-SecureString -String $password -Force -AsPlainText)

# 公開証明書を.cerファイル(秘密鍵なし)にエクスポートする
Export-Certificate `
    -Cert $cert `
    -FilePath $cerPath