Created
April 10, 2020 18:18
-
-
Save fabriciosanchez/be47b83483c20a901640106b464b1af4 to your computer and use it in GitHub Desktop.
Defining configuration for certificates in APIM.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Specify cert configuration | |
$gatewayHostname = "api.americasuniversity.net" | |
$portalHostname = "portal.americasuniversity.net" | |
$gatewayCertCerPath = "C:\AmericasUniversity\certs\api\api.americasuniversity.net.cer" | |
$gatewayCertPfxPath = "C:\AmericasUniversity\certs\api\api.americasuniversity.net.pfx" | |
$portalCertPfxPath = "C:\AmericasUniversity\certs\portaldev\portal.americasuniversity.net.pfx" | |
$gatewayCertPfxPassword = "cert-api-password" | |
$portalCertPfxPassword = "cert-portal-password" | |
# Convert to secure string before send it over HTTP | |
$certPwd = ConvertTo-SecureString -String $gatewayCertPfxPassword -AsPlainText -Force | |
$certPortalPwd = ConvertTo-SecureString -String $portalCertPfxPassword -AsPlainText -Force | |
# Create and set the hostname configuration objects for the proxy and portal | |
$proxyHostnameConfig = New-AzApiManagementCustomHostnameConfiguration ` | |
-Hostname $gatewayHostname ` | |
-HostnameType Proxy ` | |
-PfxPath $gatewayCertPfxPath ` | |
-PfxPassword $certPwd | |
$portalHostnameConfig = New-AzApiManagementCustomHostnameConfiguration ` | |
-Hostname $portalHostname ` | |
-HostnameType Portal ` | |
-PfxPath $portalCertPfxPath ` | |
-PfxPassword $certPortalPwd | |
# Ties certificates confs into APIM service | |
$apimService.ProxyCustomHostnameConfiguration = $proxyHostnameConfig | |
$apimService.PortalCustomHostnameConfiguration = $portalHostnameConfig | |
# Updates the existing APIM with the updated configuration | |
Set-AzApiManagement -InputObject $apimService |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment