英文:
How to reset Kudu cached deployment on Azure
问题
我之前在Azure Web App上有一个Node应用程序,现在改成了Go应用程序。问题是,当我部署时,Kudu给出了以下错误信息:
Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --node --sitePath "D:\home\site\repository"').
显然,之后会抱怨找不到服务器/app.js文件。
所以我尝试使用azure site deploymentscript --go
为我的应用程序生成部署脚本。
尽管我在应用程序的设置中设置了GO15VENDOREXPERIMENT=1,但它仍然抱怨依赖项。我的所有依赖项都存储在/vendor文件夹中。
然后,我在由azure site deploymentscript
命令生成的deploy.cmd
文件中设置了这个变量。
但它仍然抱怨缺少一个依赖项。请注意,现在它正在搜索本地的vendor目录,但是依赖项是存在的,我可以在Github仓库中看到它,也可以在本地看到它。
我有其他使用vendored依赖项在Azure上成功部署的Go应用程序,但是这个之前是一个Node应用程序,现在根本无法工作。
我甚至尝试注释掉deploy.cmd
中的依赖项获取器,因为所有依赖项都是本地的,所以这个步骤是不需要的。但即使这样也不起作用,因为go build
失败,抱怨缺少依赖项。它在vendor文件夹中,而且GO15VENDOREEXPERIMENT
在cmd文件和应用程序的设置中都设置为1。
那么我现在有哪些选择?
我如何告诉Kudu使用Go的默认部署,也许Azure的默认部署会起作用,因为我的其他应用程序没有本地的.deployement
和deploy.cmd
文件。
编辑
我刚刚将应用程序完全部署到一个全新的Azure Web App上,但是默认情况下该应用程序被检测为Node应用程序。我猜这是由于根目录下存在package.json,我还有一个名为main.go
的文件,其中package main
是包名。
所以也许只是由azure site deploymentscript
生成的deploy.cmd
不是最新的或其他原因?(我更新了我的azure-cli版本,因为一开始我没有使用--go标志)。
为了完整起见,这是在全新创建的应用程序上部署时Kudu的输出,与Node应用程序出现相同错误:
remote: Resolving dependencies
remote: # cd .; git clone https://github.com/org/mypkg D:\local\Tempd3397e1e014401\gopath\src\github.com\org\mypkg
remote: Building Go app to produce exe file
remote: Cloning into 'D:\local\Tempd3397e1e014401\gopath\src\github.com\org\mypkg'...
remote: fatal: could not read Username for 'https://github.com': Bad file descriptor
remote: package github.com/org/pkg/lib: exit status 128
remote: azureapp\main.go:3:8: cannot find package "github.com/org/pkg/lib" in any of:
remote: D:\local\Tempd3397e1e014401\gopath\src\azureapp\vendor\github.com\org\pkg\lib (vendor tree)
remote: Copy files for deployment
remote: D:\Program Files\Go.5.3\src\github.com\org\pkg\lib (from $GOROOT)
remote: D:\local\Tempd3397e1e014401\gopath\src\github.com\org\pkg\lib (from $GOPATH)
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
remote: Could Not Find D:\home\site\repository\azureapp.exe
remote: Copy web.config
remote: web.config already existed. Skip
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
为什么它要克隆库?这里的这一行[第二行]可能是整个问题的原因:
remote: # cd .; git clone https://github.com/org/mypkg
为什么如果设置了SET GO15VENDOREXPERIMENT=1
,它还要尝试克隆依赖项?我的其他Go应用程序没有这样做。
英文:
I previously had a Node app on Azure Web App that is now a Go app. Problem is when I deploy I get this from Kudu:
Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "D:\home\site\repository" -o "D:\home\site\deployments\tools" --node --sitePath "D:\home\site\repository"').
This obviously complains later that no server/app.js file are found.
So I tried generating a deployment script for my app with azure site deploymentscript --go
.
Even though I have the GO15VENDOREXPERIMENT=1 in the app's settings it was complaining about dependencies. All my dependencies are vendored in the /vendor folder.
I than set this variable inside the deploy.cmd
file that were generated by the azure site deploymentscript
command.
Still it's complaining that one dependencies is not there. Note that now it is searching into the local vendor tree, but the dependencies is there, I can see it in the Github repo and I see it locally as well.
I have other Go apps that deployed just fine with vendored dependencies on Azure, but this one, was a Node app previously is simply not working at all.
I even tried to comment the dependencies getter from the deploy.cmd
, since all are local this steps is not required. But even that did not work, because the go build
failed complaining about the dependency not being there. It's on the vendor folder and GO15VENDOREEXPERIMENT
is set to 1 in the cmd file and in the app application settings.
So what are my option here?
How can I tell Kudu to use a Go default deployment, maybe the one from Azure will work, since my other app do not have local .deployement
and deploy.cmd
files.
Edit
I just did a test deploy to a completely new Azure web app, and the app is detected as a Node app by default. I would guess it's due to the presence of a package.json at the root, I also have a main.go that has package main
as package name.
So maybe it's just the deploy.cmd
that is generated by azure site deploymentscript
that is not up-to-date or something? (I updated my verison of the azure-cli just FYI, since at first I did not had the --go flag).
Just for completeness here's the output of Kudu when deploying on a freshly created app, getting same error as the Node one:
remote: Resolving dependencies
remote: # cd .; git clone https://github.com/org/mypkg D:\local\Tempd3397e1e014401\gopath\src\github.com\org\mypkg
remote: Building Go app to produce exe file
remote: Cloning into 'D:\local\Tempd3397e1e014401\gopath\src\github.com\org\mypkg'...
remote: fatal: could not read Username for 'https://github.com': Bad file descriptor
remote: package github.com/org/pkg/lib: exit status 128
remote: azureapp\main.go:3:8: cannot find package "github.com/org/pkg/lib" in any of:
remote: D:\local\Tempd3397e1e014401\gopath\src\azureapp\vendor\github.com\org\pkg\lib (vendor tree)
remote: Copy files for deployment
remote: D:\Program Files\Go.5.3\src\github.com\org\pkg\lib (from $GOROOT)
remote: D:\local\Tempd3397e1e014401\gopath\src\github.com\org\pkg\lib (from $GOPATH)
remote: KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
remote: Could Not Find D:\home\site\repository\azureapp.exe
remote: Copy web.config
remote: web.config already existed. Skip
remote: Finished successfully.
remote: Running post deployment command(s)...
remote: Deployment successful.
Why is it trying to clone the library, this line here [second line] is probably what cause the entire issue:
remote: # cd .; git clone https://github.com/org/mypkg
Why if SET GO15VENDOREXPERIMENT=1
is set it is trying to clone the dependency? It's not doing that on my other Go app.
答案1
得分: 10
不确定是什么导致了那种状态,但请尝试以下操作:
- 进入Kudu控制台
- 进入
D:\home\site\deployments\tools
文件夹 - 删除
deploy.cmd
和deploymentCacheKey
文件 - 尝试重新部署
英文:
Not sure what caused that state, but try the following:
- Go to Kudu Console
- Got into the
D:\home\site\deployments\tools
folder - Delete
deploy.cmd
anddeploymentCacheKey
- Try depoying
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论