by Contributed | Sep 27, 2020 | Uncategorized
This article is contributed. See the original author and article here.
How to deploy APIM self-hosted gateway in Windows Server 2019 for test purpose
APIM self-hosted gateway is packaged as a x86-64 Linux-based Docker container.
In Windows 10, if we have Docker Desktop installed, we can easily switch the Docker to Linux Mode so we can spin up linux containers.
However, it takes a few more steps to run linux containers in windows server OS.
VM Limitation
We will need v3 series or above Azure VM to enable hyper-v feature. Here I am using D2s_V3 VM to do the demo.
Enable Hyper-V
First we need to install Hyper-V.
Run Powershell as administrator and run this command. The installation would ask for a reboot.
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
After reboot, run Powershell as administrator and run this command to check if Hyper-V is enabled.
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V
As you can see here, the state is Enabled.

Install Docker
Then we will install docker service.
To install Docker, we’ll use the OneGet provider PowerShell module. The provider will enable the containers feature on your machine and install Docker, which will require a reboot.
Run the below commands:
Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
Install-Package -Name docker -ProviderName DockerMsftProvider
Restart-Computer -Force
After the reboot, run docker info to check if the docker is successfully installed.
docker info
Now let’s try to pull the self-hosted gateway image and run it.
docker run -it --rm mcr.microsoft.com/azure-api-management/gateway
The docker will complain the operating system does not match.
Switch to Linux Mode
So we are going to switch the Docker to linux mode.
We will configure the docker to run in experimental mode.
Create or modify a json file at this path.
C:ProgramDatadockerconfigdaemon.json
We will add or change the ‘experimental’ attribute to true here.

Then we restart docker.
restart-service docker
Run docker info again, we can see that the LCOW setting is there.
Finally we need to download LinuxKit from Github.
Invoke-Webrequest -UseBasicParsing -uri "https://github.com/linuxkit/lcow/releases/download/v4.14.35-v0.3.9/release.zip" -outfile ".release.zip"
Unzip it to this path.
Expand-Archive ".release.zip" -DestinationPath "C:Program FilesLinux Containers."

Restart the docker service again.
restart-service docker
Try the linux container
The environment should be good to run linux container now.
docker run -d --rm --name test-apim mcr.microsoft.com/azure-api-management/gateway
-d here means detach, which means running the container at the background.
–rm means when we kill the container, docker will remove the container, just to avoid dangling containers here.
If we run a docker container list, we can see the self-hosted gateway container is running there.
docker container ls

Terminate the container
Run docker kill to terminate the container.
test-apim is the name we just gave this container using –name flag when we ran it.
docker kill test-apim
Actually Run it
Now we will connect this container to our APIM and make it an actual gateway.
We create an gateway in the Gateway blade of APIM Azure Portal.

Download the env.conf file from the just created gateway. Put it into the path that we are going to run the ‘docker run’ command.
docker run -d -p 80:8080 -p 443:8081 --name yixwan-self-hosted-gateway --env-file env.conf mcr.microsoft.com/azure-api-management/gateway
The -p here is publish(expose). It exposes container’s 8080 and 8081 port to the host machine’s 80 and 443 port.
Once the container is up, any requests that hit the mapped port will go through this self-hosted gateway.
Make sure in API setting that you have included your gateway.
Now we will test use curl or any web request tool, we can send request to http://localhost:80 or https://localhost:443 to see if our self-hosted gateway is working.
Purpose
Currently the LinuxKit on Github is not being developed any more, so this is just a quick way to demonstrate that APIM self-hosted gateway can be deployed in windows server 2019.
by Contributed | Sep 25, 2020 | Uncategorized
This article is contributed. See the original author and article here.
One customer had a SQL2016 SP1 instance. We can login this instance without any issue. But when we tried to apply SQL2016 SP2 in this server. We cannot find SQL instance in below panel. Only ‘Shared Features’ are listed.

I decompiled SQL setup dlls. It seems that SQL setup should check below registry key to Enumerate SQL Server features.
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUnistall

We found below key was missing in customer’s environment. We tried to remove below key in my testing environment. We can reproduce the same issue.
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstallMicrosoft SQL Server 13
However, after adding back above key. SQL instance is still not found in patching in customer’s environment. So we still need to check the keys in ‘HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUnistall’.
We found 2 product codes are related with SQL Server 2016 database Engine service.


But according to the name of msi package, {51574D2C-DE28-4441-BDC2-967F0FFC0918} is the real database engine service product code.
We can also run PowerShell scripts to verify.


We found below registry keys have {0C457EC3-E998-4041-B856-908D5A2C1708} in “ProductCode”. But it’s incorrect.
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL13.MSSQLSERVERSetup]
[HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL13.MSSQLSERVERSetupSQL_Engine_Core_Inst]
We finally resolved this issue by making below changes. Those 2 wrong product codes caused this issue.
- [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL13.MSSQLSERVERSetup]
“ProductCode”=”{0C457EC3-E998-4041-B856-908D5A2C1708}” change to {51574D2C-DE28-4441-BDC2-967F0FFC0918}
- [HKEY_LOCAL_MACHINESOFTWAREMicrosoftMicrosoft SQL ServerMSSQL13.MSSQLSERVERSetupSQL_Engine_Core_Inst]
“ProductCode”=”{0C457EC3-E998-4041-B856-908D5A2C1708}” change to {51574D2C-DE28-4441-BDC2-967F0FFC0918}
Recent Comments