Skip to content

Commit c530746

Browse files
authored
Update service-fabric-powershell-add-application-certificate.md
Just tidying up the script to make these steps easier to follow, had to work a few things out depending on what steps I took like some of the variable names are wrong and one method adds a certificate to the key vault while another sets a secret.
1 parent 43077da commit c530746

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

articles/service-fabric/scripts/service-fabric-powershell-add-application-certificate.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ $CertName= ""
4444
$CertPassword= ""
4545
$PathToPFX= ""
4646
47-
$Cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate2 $PathToPFX, $CertPassword
48-
49-
$bytes = [System.IO.File]::ReadAllBytes($ExistingPfxFilePath)
47+
$bytes = [System.IO.File]::ReadAllBytes($PathToPFX)
5048
$base64 = [System.Convert]::ToBase64String($bytes)
5149
$jsonBlob = @{
5250
data = $base64
@@ -70,7 +68,12 @@ $ResourceGroupName = ""
7068
$VMSSName = ""
7169
$CertStore = "My" # Update this with the store you want your certificate placed in, this is LocalMachine\My
7270
71+
# If you have added your certificate to the keyvault certificates, use
7372
$CertConfig = New-AzVmssVaultCertificateConfig -CertificateUrl (Get-AzKeyVaultCertificate -VaultName $VaultName -Name $CertName).SecretId -CertificateStore $CertStore
73+
74+
# Otherwise, if you have added your certificate to the keyvault secrets, use
75+
$CertConfig = New-AzVmssVaultCertificateConfig -CertificateUrl (Get-AzKeyVaultSecret -VaultName $VaultName -Name $CertName).Id -CertificateStore $CertStore
76+
7477
$VMSS = Get-AzVmss -ResourceGroupName $ResourceGroupName -VMScaleSetName $VMSSName
7578
7679
# If this KeyVault is already known by the virtual machine scale set, for example if the cluster certificate is deployed from this keyvault, use
@@ -94,7 +97,8 @@ This script uses the following commands: Each command in the table links to comm
9497
| Command | Notes |
9598
|---|---|
9699
| [New-AzKeyVaultCertificatePolicy](/powershell/module/az.keyvault/New-AzKeyVaultCertificatePolicy) | Creates an in-memory policy representing the certificate |
97-
| [Add-AzKeyVaultCertificate](/powershell/module/az.keyvault/Add-AzKeyVaultCertificate)| Deploys the policy to Key Vault |
100+
| [Add-AzKeyVaultCertificate](/powershell/module/az.keyvault/Add-AzKeyVaultCertificate)| Deploys the policy to Key Vault Certificates |
101+
| [Set-AzKeyVaultSecret](/powershell/module/az.keyvault/Set-AzKeyVaultSecret)| Deploys the policy to Key Vault Secrets |
98102
| [New-AzVmssVaultCertificateConfig](/powershell/module/az.compute/New-AzVmssVaultCertificateConfig) | Creates an in-memory config representing the certificate in a VM |
99103
| [Get-AzVmss](/powershell/module/az.compute/Get-AzVmss) | |
100104
| [Add-AzVmssSecret](/powershell/module/az.compute/Add-AzVmssSecret) | Adds the certificate to the in-memory definition of the virtual machine scale set |

0 commit comments

Comments
 (0)