I am using Azure
powershell to create an APIM management resources as below:
.
.
.
$apimService = New-AzApiManagement `
-ResourceGroupName $resGroupName `
-Location $location `
-Name $apimServiceName `
-Organization $apimOrganization `
-AdminEmail $apimAdminEmail `
-VirtualNetwork $apimVirtualNetwork `
-VpnType "Internal" `
-Sku "Developer"
But, since APIM takes a lot of time to create, the powershell terminal times out and I have to reconnect. What happens is, the variable $apimService
is set to null after reconnecting to the terminal again.
Because of that, I cannot execute the following command:
.
.
.
$proxyHostnameConfig = New-AzApiManagementCustomHostnameConfiguration `
-Hostname $gatewayHostname `
-HostnameType Proxy `
-PfxPath $gatewayCertPfxPath `
-PfxPassword $certPwd
// this command complains as variable $apimService is null
$apimService.ProxyCustomHostnameConfiguration = $proxyHostnameConfig
What is the best way to preserve these variable values even after a 2 hours of time? Because APIm takes nearly 1 hour of time to complete when SKU is Developer
Can someone please help me?
Thank you,
Best Regards
2
Answers
I tried to reproduce the same in my environment and below is the result
I have used below powershell script to create an API Management
When i ran the above powershell commands, API Management got is created successfully without getting timedout error, like below.
I have tested same script in Azure Cloud Shell.
$global
. This will ensure global scope which will allow you to get values in console.Once it’s finished creating, you can use Get-AzApiManagement to repopulate your variable.
You’ll also need to do Set-AzApiManagement to actually apply the change.