也许情况并非总是如此,但目前完全可以在没有任何定制工作的情况下做到这一点。只需编辑您的服务.csdef
(云服务定义)文件以包含以下内容 - 或者,如果使用 Visual Studio,请使用辅助角色的属性面板:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MyService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-10.2.2">
<WorkerRole name="MyService.Backend" ... >
<Certificates>
<Certificate name="backend.example.com.selfsigned" storeLocation="LocalMachine" storeName="My" />
<Certificate name="frontend.example.com.selfsigned" storeLocation="LocalMachine" storeName="TrustedPeople" />
</Certificates>
<Endpoints>
<InternalEndpoint name="Internal" protocol="tcp" port="..." />
</Endpoints>
...
</WorkerRole>
<WebRole name="MyService.Frontend" ... >
<Sites>
<Site name="Web">
<Bindings>
<Binding name="WebsitePublicEndpoint" endpointName="Insecure" />
<Binding name="WebsitePublicEndpoint" endpointName="Secure" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Insecure" protocol="http" port="80" />
<InputEndpoint name="Secure" protocol="https" port="443" certificate="example.com" />
</Endpoints>
<Certificates>
<Certificate name="backend.example.com" storeLocation="LocalMachine" storeName="TrustedPeople" />
<Certificate name="frontend.example.com" storeLocation="LocalMachine" storeName="My" />
<Certificate name="example.com" storeLocation="LocalMachine" storeName="My" />
</Certificates>
...
</WebRole>
</ServiceDefinition>
另请参阅此论坛主题和工作人员角色服务定义文件架构文档。
此外,Azure 门户现在支持上传.cer
(仅限公钥)证书文件。您可能必须更改“打开文件”对话框的选择过滤器 - 默认情况下,它设置为.pfx
仅查找文件。