Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move more LA steps under conditional #2270

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions e2e/test/prerequisites/E2ETestsSetup/e2eTestsSetup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,8 @@ az role assignment create --assignee $systemIdentityPrincipal --role "Storage Bl
# Uploading root CA certificate to IoT hub and verifying
##################################################################################################################################

$certExits = az iot hub certificate list -g $ResourceGroup --hub-name $iotHubName --query "value[?name=='$hubUploadCertificateName']" --output tsv
if ($certExits)
$certExists = az iot hub certificate list -g $ResourceGroup --hub-name $iotHubName --query "value[?name=='$hubUploadCertificateName']" --output tsv
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
if ($certExists)
{
Write-Host "`nDeleting existing certificate from IoT hub."
$etag = az iot hub certificate show -g $ResourceGroup --hub-name $iotHubName --name $hubUploadCertificateName --query 'etag'
Expand Down Expand Up @@ -593,8 +593,8 @@ $symmetricKeySampleEnrollmentPrimaryKey = az iot dps enrollment show -g $Resourc
##################################################################################################################################

$dpsIdScope = az iot dps show -g $ResourceGroup --name $dpsName --query 'properties.idScope' --output tsv
$certExits = az iot dps certificate list -g $ResourceGroup --dps-name $dpsName --query "value[?name=='$uploadCertificateName']" --output tsv
if ($certExits)
$certExists = az iot dps certificate list -g $ResourceGroup --dps-name $dpsName --query "value[?name=='$uploadCertificateName']" --output tsv
if ($certExists)
{
Write-Host "`nDeleting existing certificate from DPS."
$etag = az iot dps certificate show -g $ResourceGroup --dps-name $dpsName --certificate-name $uploadCertificateName --query 'etag'
Expand Down Expand Up @@ -653,24 +653,24 @@ az iot dps enrollment create `

if ($EnableIotHubSecuritySolution)
{
Write-Host "`nCreating a self-signed certificate and placing it in $ResourceGroup."
Write-Host "`nCreating a self-signed certificate lor LA and placing it in $ResourceGroup."
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
az ad app credential reset --id $logAnalyticsAppId --create-cert --keyvault $keyVaultName --cert $ResourceGroup --output none
Write-Host "`nSuccessfully created a self signed certificate for your application $logAnalyticsAppRegnName in $keyVaultName key vault with cert name $ResourceGroup."
}

Write-Host "`nFetching the certificate binary."
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
$selfSignedCerts = "$PSScriptRoot\selfSignedCerts"
if (Test-Path $selfSignedCerts -PathType Leaf)
{
Remove-Item -r $selfSignedCerts
}
Write-Host "`nFetching the certificate binary for LA."
$selfSignedCerts = "$PSScriptRoot\selfSignedCerts"
if (Test-Path $selfSignedCerts -PathType Leaf)
{
Remove-Item -r $selfSignedCerts
}

az keyvault secret download --file $selfSignedCerts --vault-name $keyVaultName -n $ResourceGroup --encoding base64
$fileContent = Get-Content $selfSignedCerts -AsByteStream
$fileContentB64String = [System.Convert]::ToBase64String($fileContent);
az keyvault secret download --file $selfSignedCerts --vault-name $keyVaultName -n $ResourceGroup --encoding base64
$fileContent = Get-Content $selfSignedCerts -AsByteStream
$fileContentB64String = [System.Convert]::ToBase64String($fileContent);

Write-Host "`nSuccessfully fetched the certificate bytes. Removing the cert file from the disk."
Remove-Item -r $selfSignedCerts
Write-Host "`nSuccessfully fetched the certificate bytes for LA. Removing the cert file from the disk."
Remove-Item -r $selfSignedCerts
}

###################################################################################################################################
# Store all secrets in a KeyVault - Values will be pulled down from here to configure environment variables
Expand Down Expand Up @@ -698,10 +698,8 @@ $keyvaultKvps = @{
"DPS-GROUPX509-CERTIFICATE-CHAIN" = $dpsGroupX509CertificateChain;
"STORAGE-ACCOUNT-CONNECTION-STRING" = $storageAccountConnectionString;
"MSFT-TENANT-ID" = "72f988bf-86f1-41af-91ab-2d7cd011db47";
"LA-AAD-APP-ID" = $logAnalyticsAppId;
"IOTHUB-CLIENT-ID" = $iotHubAadTestAppId;
"IOTHUB-CLIENT-SECRET" = $iotHubAadTestAppPassword;
"LA-AAD-APP-CERT-BASE64" = $fileContentB64String;
"DPS-GLOBALDEVICEENDPOINT-INVALIDCERT" = "invalidcertgde1.westus.cloudapp.azure.com";
"PIPELINE-ENVIRONMENT" = "prod";
"HUB-CHAIN-DEVICE-PFX-CERTIFICATE" = $iothubX509ChainDevicePfxCertificate;
Expand Down Expand Up @@ -741,6 +739,8 @@ $keyvaultKvps = @{
if ($EnableIotHubSecuritySolution)
{
$keyvaultKvps.Add("LA-WORKSPACE-ID", $workspaceId)
$keyvaultKvps.Add("LA-AAD-APP-CERT-BASE64", $fileContentB64String)
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
$keyvaultKvps.Add("LA-AAD-APP-ID", $logAnalyticsAppId)
}

Write-Host "`nWriting secrets to KeyVault $keyVaultName."
Expand Down