如何通过测试部署ASP.NET Web-API [英] How to deploy asp.net web-api with tests

查看:109
本文介绍了如何通过测试部署ASP.NET Web-API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Azure App Service

我已经成功部署了一个Web-api,无需进行单元测试就可以进行天蓝色.我使用本地git推送到天蓝色,效果很好

现在,我希望能够实现两件事:

1/具有一个既包含测试目录又包含应用程序目录的目录.我希望能够以与上述相同的方式使用本地git推送到天蓝色,并且不会被测试目录弄糊涂

2/从长远来看,在将测试部署到天蓝色之前,请让我的测试在CI/CD服务上运行.理想的情况是能够推送到git分支,让测试自动运行,然后在github上查看是否通过测试,然后在我执行测试 将PR合并到母版,它将自动部署到天蓝色

我使用asp.net核心创建了一个非常简单的web-api:https://github.com/samrae7/todoApi

我使用了Azure DevOps并将我的git repo链接到了那里.我成功运行了一个构建,但是在部署时遇到了一个错误:`

资源"TodoApi"不存在.资源应在部署之前存在.

解决方案

嗨Vinniebaby77 ,为什么要在一个目录中放置一个测试目录和一个应用程序目录是有原因的?相反,您可以将应用程序部署到 自动交换已启用以避免混淆.对于第二个问题,您的错误看起来与此类似 SO 线程.

希望有帮助.如果您还有其他问题,请告诉我.


I am just getting started with Azure App Service

I have successfully deployed a web-api to azure WITHOUT unit tests. I use local git to push to azure and it works well

Now I want to be able to achieve two things:

1/ Have a directory that includes both a test directory and an app directory. I want to be able to push to azure using local git in the same way as above and for it to not get confused by the test directory

2/ In the longer run, have my tests run on a CI/CD service before they deploy to azure. The ideal would be to be able to push to a git branch, have the tests run automatically and then on github I would see whether the tests passed or not and then when I merge the PR to master it would automatically deploy to azure

I created a very simple web-api using asp.net core: https://github.com/samrae7/todoApi

I used Azure DevOps and linked my git repo there. I successfully ran a build but when it came to deploying I got an error: `

Resource 'TodoApi' doesn't exist. Resource should exist before deployment.`

解决方案

Hi Vinniebaby77, is there a reason why you want to have put a test directory and a app directory in one directory? Instead, you could deploy your app to a staging slot with auto swap enabled to avoid the confusion. For your second question, your error looks similar to this SO thread.

Hope that helps. Let me know if you have additional questions.


这篇关于如何通过测试部署ASP.NET Web-API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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