ASP.NET 5 Azure的部署模板创建失败的SQL Server [英] ASP.NET 5 Azure template deployment failed creating SQL Server

查看:135
本文介绍了ASP.NET 5 Azure的部署模板创建失败的SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了一个新的默认ASP.NET 5 Web应用程序,并选择部署到Azure上。这工作得很好,但如果我重新尝试,并添加一个蔚蓝的SQL数据库,然后我得到下面,因为它试图创建新的资源组的错误。


  

微软的Visual Studio


  
  

模板部署失败。部署操作状态:


  
  

失败: /subscriptions/81368473107b/resourceGroups/DJWTestDb/providers/Microsoft.Sql/servers/djwtestdbdbserver ()


  
  

错误(InvalidApiVersionParameter):该API版本'2.0'是无效的。 API版本必须是以下格式:YYYY-MM-DD。此格式支持以下后缀:' - preVIEW,-α,-β,-rc,-private preVIEW。


  
  

成功: /subscriptions/81368473107b/resourceGroups/DJWTestDb/providers/Microsoft.Web/serverfarms/DJWTestDbPlan ()



解决方案

我已经运行到了同样的问题,刚刚注册让你知道。看来,它现在是不可能的(谁知道为什么,但我看着你,ASP.NET RC1),而部署SQL服务器进行发布。但是,它的工作发表的无一做一个门户,然后通过您的Web.config将它们连接

起初我还以为这是所有新的更新到Visual Studio(截至15年5月12日),但更新后,我仍然得到同样的问题。我不知道是否需要为这种解决方法的新的更新,但是这就是我正在同这一点。

步骤:

1 发布您的API应用程序正常,不包括SQL服务器。

2 转到您的Azure门户网站,定位到SQL数据库选项卡。

第二步

3。使用现有的服务器创建一个新的数据库,或者只是做一个新的数据库服务器,如果你还没有一个。

第三步

4。:当它完成后(可能需要第二次为它在列表中显示出来),单击新的数据库,它的设置将会出现。你想要去的显示数据库连接字符串选项。

显示数据库连接字符串

5 保存ADO.NET连接字符串!

ADO.NET连接字符串

6。返回到您的项目在Visual Studio并导航到Web.config文件中。

Web.config文件

7。在是connectionStrings头,找到你的数据库环境。它应该有类似的格式YOURDATABASENAMEContext,或类似的名称。它可能会成为第二个进入那里。更换(先保存副本,请访问下面的注释为什么)了的connectionString的内部与刚创建的数据库的ADO.NET连接字符串。

的connectionString

8。发布,它应该工作!

注意:此解决方法,如果遵循从字面上看,是指程序将不再在本地功能(例如,启动应用程序,而不是将其发布),因为它会寻找在连接字符串数据库。它是用于测试原始状态,你可以返回它,然后在发布时使用湛蓝的连接字符串,但我敢肯定有一个更优雅的方式来做到这一点。

I have added a new default ASP.NET 5 web app, and chosen to deploy to AZURE. This works fine, but if I retry and add a azure sql db, then I get the error below as it tries to create the new resource group.

Microsoft Visual Studio

Template deployment failed. Deployment operation statuses:

Failed: /subscriptions/81368473107b/resourceGroups/DJWTestDb/providers/Microsoft.Sql/servers/djwtestdbdbserver ()

error (InvalidApiVersionParameter): The api-version '2.0' is invalid. The api version must be of the following format: yyyy-MM-dd. This format supports the following suffixes: '-preview,-alpha,-beta,-rc,-privatepreview'.

Succeeded: /subscriptions/81368473107b/resourceGroups/DJWTestDb/providers/Microsoft.Web/serverfarms/DJWTestDbPlan ()

解决方案

I've been running into the same problem, just registered to let you know. It seems that it isn't possible right now (who knows why, but I'm looking at you, ASP.NET RC1) to publish while deploying an SQL server. However, it DOES work to publish without one and make one in the portal, and then connect them through your Web.config.

At first I thought it was all of the new updates to Visual Studio (as of 5/12/15), but I was still getting the same problems after updating. I'm not sure if the new updates are required for this workaround, but that's what I was working with for this.

Steps:

1. Publish your API app as normal, without including an SQL server.

2. Go to your Azure portal and navigate to the "SQL Databases" tab.

3. Create a new database using your existing server, or just make a new database server if you don't have one yet.

4. When it's done (it may take a second for it to show up in the list), click on the new database and it's settings will appear. You want to go to the "Show Database Connection Strings" option.

5. Save the ADO.NET connection string!

6. Go back to your project in Visual Studio and navigate to the Web.config file.

7. In the "connectionStrings" header, find your database context. It should have a name formatted like YOURDATABASENAMEContext, or something similar. It'll probably be the second entry there. Replace (save a copy first, see note below for why) the inside of the "connectionString" with the ADO.NET connection string of the database you just created.

8. Publish and it should work!

NOTE: This workaround, if followed literally, means the program won't function locally anymore (e.g. starting the app rather than publishing it) since it will be looking for that database in the connection strings. You could return it to it's original state for testing, and then use the azure connection string when publishing, although I'm sure there's a more elegant way to do it.

这篇关于ASP.NET 5 Azure的部署模板创建失败的SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆