简体   繁体   English

Azure 经典云服务配置本地 vs 云

[英]Azure classic cloud service configuration local vs cloud

Problem #1: I have a classic cloud service running a single web site role.问题 1:我有一个运行单个网站角色的经典云服务。 I would like to differentiate between the way it is debugged locally versus how it is deployed to the cloud.我想区分它在本地调试的方式与如何部署到云中的方式。 Specifically I would like the local site to run on HTTP and the cloud service to run on HTTPS.具体来说,我希望本地站点在 HTTP 上运行,而云服务在 HTTPS 上运行。 The main reason for this is that we don't want to have to install the same cert on all the developers' machines.这样做的主要原因是我们不想在所有开发人员的机器上安装相同的证书。 However, the endpoints are defined in the common "ServiceDefinition.csdef", NOT in the two "ServiceConfiguration.cscfg" files ("local" and "cloud").但是,端点是在通用的“ServiceDefinition.csdef”中定义的,而不是在两个“ServiceConfiguration.cscfg”文件(“local”和“cloud”)中定义的。 So, how do I set up different endpoints for local versus cloud?那么,如何为本地和云设置不同的端点?

Problem #2: I would like, especially in the cloud, to have a site running on HTTP that simply redirects the user to the HTTPS site.问题#2:我希望,尤其是在云中,有一个在 HTTP 上运行的站点,该站点只是将用户重定向到 HTTPS 站点。 How would I set that up?我该如何设置?

I realize these questions may not have sufficient detail, but I didn't want to write a book.我意识到这些问题可能不够详细,但我不想写一本书。 Please feel free to ask for clarification.请随时要求澄清。

Thanks a lot in advance!非常感谢!

Partial answer to your questions:部分回答您的问题:

Problem #2: I would like, especially in the cloud, to have a site running on HTTP that simply redirects the user to the HTTPS site.问题#2:我希望,尤其是在云中,有一个在 HTTP 上运行的站点,该站点只是将用户重定向到 HTTPS 站点。 How would I set that up?我该如何设置?

For this, you can simply rely on web.config transforms.为此,您可以简单地依赖 web.config 转换。 In your web.release.config you can set a redirection rule which will redirect http requests to https.在您的 web.release.config 中,您可以设置重定向规则,将 http 请求重定向到 https。 Something like the following:类似于以下内容:

<rewrite>
  <rules>
    <rule name="HTTP/S to HTTPS Redirect" enabled="true" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTPS}" pattern="^OFF$" />
      </conditions>
      <action type="Redirect" url="https://{SERVER_NAME}/{R:1}" redirectType="Permanent" />
    </rule>
  </rules>
</rewrite>

Similar thing would just not be present in your web.debug.config (or web.config).类似的东西不会出现在您的 web.debug.config(或 web.config)中。

Specifically I would like the local site to run on HTTP and the cloud service to run on HTTPS.具体来说,我希望本地站点在 HTTP 上运行,而云服务在 HTTPS 上运行。

For this, the way I have handled it in the past when I worked on Cloud Services is basically I created separate cloud projects for each environment (WebApp.Azure.Dev, WebApp.Azure.Prod etc.).为此,我过去处理云服务时的处理方式基本上是为每个环境(WebApp.Azure.Dev、WebApp.Azure.Prod 等)创建单独的云项目。 This way I would get separate csdef file for each environment.这样我就可以为每个环境获得单独的 csdef 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM