Skip to content

Commit b3726c3

Browse files
committed
Created deployment scripts for SF Linux
1 parent 3385c63 commit b3726c3

12 files changed

Lines changed: 2142 additions & 4 deletions
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Param(
2+
[parameter(Mandatory=$true)][string]$vaultName,
3+
[parameter(Mandatory=$true)][string]$certName,
4+
[parameter(Mandatory=$true)][string]$certPwd,
5+
[parameter(Mandatory=$true)][string]$subjectName,
6+
[parameter(Mandatory=$false)][string]$ValidityInMonths=12,
7+
[parameter(Mandatory=$true)][string]$saveDir
8+
)
9+
10+
11+
#Log in Azure Account
12+
Login-AzureRmAccount
13+
14+
15+
# Create Cert in KeyVault
16+
Write-Host "Creating certificate in Azure KeyVault..." -ForegroundColor Yellow
17+
$policy = New-AzureKeyVaultCertificatePolicy -SubjectName $subjectName -IssuerName Self -ValidityInMonths $ValidityInMonths
18+
Add-AzureKeyVaultCertificate -VaultName $vaultName -Name $certName -CertificatePolicy $policy
19+
20+
# Downloading Certificate
21+
Write-Host "Downloading Certificate from KeyVault..." -ForegroundColor Yellow
22+
23+
$Stoploop = $false
24+
$Retrycount = 0
25+
26+
do {
27+
try {
28+
29+
$kvSecret = Get-AzureKeyVaultSecret -VaultName $vaultName -Name $certName -ErrorAction SilentlyContinue
30+
$kvSecretBytes = [System.Convert]::FromBase64String($kvSecret.SecretValueText)
31+
$certCollection = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2Collection
32+
$certCollection.Import($kvSecretBytes,$null,[System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
33+
$protectedCertificateBytes = $certCollection.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPwd)
34+
[System.IO.File]::WriteAllBytes($saveDir + "\" + $certName + ".pfx", $protectedCertificateBytes)
35+
36+
$Stoploop = $true
37+
Write-Host "Finished!" -ForegroundColor Yellow
38+
}
39+
catch {
40+
if ($Retrycount -gt 5){
41+
$Stoploop = $true
42+
Write-Host "Not possible to retrieve the certificate!" -ForegroundColor Yellow
43+
}
44+
else {
45+
Start-Sleep -Seconds 20
46+
$Retrycount = $Retrycount + 1
47+
}
48+
}
49+
}
50+
While ($Stoploop -eq $false)
51+
52+
# Show Certificate Values
53+
Get-AzureKeyVaultCertificate -VaultName $vaultName -Name $certName
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Deploying Azure Service Fabric (No Secured)
2+
3+
The ARM template `servicefabricdeploy.json` and its parameter file (`servicefabricdeploy.parameters.json`) are used to create a service fabric cluster environment for linux containers.
4+
5+
## Editing servicefabricdeploy.parameters.json file
6+
7+
Edit the following params in `servicefabricdeploy.parameters.json` file to set your values:
8+
9+
- clusterName: Name of your SF cluster
10+
- dnsName: Name assigned to your SF dns
11+
- adminUserName: user name for administration
12+
- adminPassword: user password for administration
13+
14+
Optionally, you can modify which ports are opened in the LoadBalancer for accessing externally to the apps:
15+
16+
- webMvcHttpPort: port externally exposed for the WebMVC app
17+
- webSpaHttpPort: port externally exposed for the WebSPA app
18+
- webStatusHttpPort: port externally exposed for the WebStatus app
19+
- IdSrvHttpRule: port externally exposed for the Identity app
20+
21+
## Deploy the template
22+
23+
Once parameter file is edited you can deploy it using [create-resources script](../readme.md).
24+
25+
i. e. if you are in windows, to deploy sql databases in a new resourcegroup located in westus, go to `deploy\az` folder and type:
26+
27+
```
28+
create-resources.cmd servicefabric\LinuxContainers\servicefabricdeploy newResourceGroup -c westus
29+
```
30+
## Deploy eShopOnServiceFabric with Visual Studio.
31+
32+
Alternatively, instead of using ARM templates, you can deploy eShop on service fabric directly by publishing the project eShopOnServiceFabric in eShopOnContainers-ServicesAndWebApps.sln with Visual Studio publish tool.
33+
34+
# Deploying Azure Service Fabric (Secured)
35+
36+
The ARM template `servicefabricdeploysecured.json` and its parameter file (`servicefabricdeploysecured.parameters.json`) are used to create a service fabric cluster environment for linux containers secured with a certificate.
37+
38+
## Create Azure Keyvault service
39+
Go to PortalAzure and create a Keyvault service. Make sure Enable access for deployment checkboxes are selected.
40+
41+
<img src="../../../../img/sf/create-kv.png">
42+
43+
## Generate a certificate in Azure Keyvault
44+
Execute the gen-keyvaultcert.ps1 script to generate and download a certificate from Keyvault.
45+
46+
```
47+
.\gen-keyvaultcert.ps1 -vaultName <your_keyvault_service> -certName <your_cert_name> -certPwd <your_cert_pwd> -subjectName CN=<your_sf_dns_name>.westeurope.cloudapp.azure.com -saveDir C:\Users\<user>\Downloads
48+
49+
```
50+
## Install the certificate
51+
Install the certificate under 'Current User' store location and check it as exportable.
52+
53+
<img src="../../../../img/sf/install-cert.png">
54+
55+
## Editing servicefabricdeploysecured.parameters.json file
56+
57+
Edit the following params in `servicefabricdeploysecured.parameters.json` file to set your values:
58+
59+
- clusterName: Name of your SF cluster
60+
- dnsName: Name assigned to your SF dns
61+
- adminUserName: user name for administration
62+
- adminPassword: user password for administration
63+
- sourceVaultValue: keyvault resource id (check azure keyvault properties)
64+
- certificateUrlValue: certificate url (check azure Keyvault certificate properties)
65+
- certificateThumbprint: certificate thumbprint (check azure Keyvault certificate properties)
66+
67+
Optionally, you can modify which ports are opened in the LoadBalancer for accessing externally to the apps:
68+
69+
- webMvcHttpPort: port externally exposed for the WebMVC app
70+
- webSpaHttpPort: port externally exposed for the WebSPA app
71+
- webStatusHttpPort: port externally exposed for the WebStatus app
72+
- IdSrvHttpRule: port externally exposed for the Identity app
73+
74+
## Deploy the template
75+
76+
Once parameter file is edited you can deploy it using [create-resources script](../readme.md).
77+
78+
```
79+
create-resources.cmd servicefabric\LinuxContainers\servicefabricdeploysecured newResourceGroup -c westus
80+
```
81+
## Deploy eShopOnServiceFabric with Visual Studio.
82+
83+
Modify the cloud.xml file of each Service Fabric application in PublishProfile directory and set your certificate settings to be able to deploy eshopOnContainers in the secured cluster:
84+
85+
<img src="../../../../img/sf/cloud_publishProfile.png">
86+
87+
88+

0 commit comments

Comments
 (0)