Azure Stack开发工具包的管理通常需要通过远程桌面登录到ASDK的宿主机上才可以打开管理界面,包括以下两个界面:
https://adminportal.local.azurestack.external/
https://portal.local.azurestack.external/
有时候需要多人同时登录进行测试,或是希望可以不要那么麻烦,每次都要打开远程桌面,那么还可以通过VPN连接到Azure Stack开发工具包环境。VPN连接工具包含在Azure Stack的管理工具中。在这里列举一下操作步骤,由于VPN使用的是L2TP协议,因此无法穿透Azure的NAT,因此示例配置是基于Azure上同VNET的另一台虚机进行的。
因为VPN连接命令需要引用Azure Stack的连接管理命令,所以首先需要安装Azure Stack工具包,在客户端虚机上用以下命令:
Install-Module-Name 'AzureRm.Bootstrapper'
Install-AzureRmProfile-profile '2017-03-09-profile' -Force
Install-Module-Name AzureStack -RequiredVersion 1.2.11
安装了Powershell模块后,需要下载准备管理工具:
[Net.ServicePointManager]::SecurityProtocol =[Net.SecurityProtocolType]::Tls12
Invoke-WebRequest -uri "https://github.com/Azure/AzureStack-Tools/archive/master.zip" -OutFile master.zip
然后将这个工具包解压缩,
Expand-Archive master.zip -DestinationPath. -Force
进入解压后的目录,并执行以下命令,导入连接模块。
Import-Module.\Connect\AzureStack.Connect.psm1
接下来就可以创建VPN连接到ASDK环境了,VPN隧道会将客户端虚机连接到ASDK的网络环境,这样就可以解析刚才的两个URL了。
在建立VPN连接的过程中,会将ASDK的证书下载到客户端,这样就可以确保通讯是经过加密的了。
执行以下Powershell命令,来建立VPN:
Set-ExecutionPolicyRemoteSigned
$hostIP ="ASDK 在VNET里的私有IP"
Set-Itemwsman:\localhost\Client\TrustedHosts -Value $hostIP -Concatenate
$Password =ConvertTo-SecureString "ASDK管理员密码" -AsPlainText -Force
Add-AzsVpnConnection-ServerAddress $hostIP -Password $Password
执行了以上命令,就可以在网络里看到新建了一个名为Azurestack的VPN连接
接下来执行这条命令:
Connect-AzsVpn -Password $Password
会将ASDK的证书下载到客户端
然后在网络中编辑azurestack的VPN连接参数,将用户名和密码设置为azurestack\azurestackadmin 和它的密码。
然后就可以点击连接了,等VPN建立成功后,可以从客户端访问管理界面了。
https://adminportal.local.azurestack.external/
https://portal.local.azurestack.external/
此外,强烈建议不要将ASDK虚机直接关机或重启,这将引起难以预料的问题,我是有惨痛的教训的。在关机或重启前,建议用以下命令停止Azure Stack服务:
Enter-PSSession -ComputerName AzS-ERCS01-ConfigurationName PrivilegedEndpoint
[AzS-ERCS01]: PS> Stop-AzureStack
在虚机重启后在用以下命令来启动Azure Stack服务:
Enter-PSSession -ComputerName AzS-ERCS01 -ConfigurationNamePrivilegedEndpoint
[AzS-ERCS01]: PS> Get-ActionStatusStart-AzureStack
完成后可以通过以下命令来验证,如果都是Pass状态就说明没有问题了。
Enter-PSSession -ComputerName AzS-ERCS01-ConfigurationName PrivilegedEndpoint
[AzS-ERCS01]: PS> Test-AzureStack
原文 : https://mp.weixin.qq.com/s/bt-O0-jmqM-l9bbcEEKMLQ