这是我部署到Azure功能的旧项目:
<root-directory>
├── README.md
├── dist
├── bin
├── dependencies
├── host.json
├── local.settings.json
├── node_modules
├── package-lock.json
├── package.json
├── sealworker
│ ├── constants
│ ├── errors
│ ├── function.json
│ ├── index.ts
│ ├── interfaces
│ ├── sample.dat
│ ├── services
│ ├── utils
│ ├── sealworkerfunction.ts // this will be removed
│ └── worker.ts // this will be removed
└── tsconfig.json
删除文件后,这是本地的新项目:
<root-directory>
├── README.md
├── ...
├── sealworker
│ ├── constants
│ ├── errors
│ ├── function.json
│ ├── index.ts
│ ├── interfaces
│ ├── sample.dat
│ ├── services
│ └── utils
└── tsconfig.json
这就是我进行 zip 部署的方式:
rm -rf dist/ && npm run-script build && zip -r azure_function.zip . && az functionapp deployment source config-zip -g sealworkerdevda1 -n sealworkerfunction2 --src azure_function.zip
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
{
"active": true,
"author": "N/A",
"author_email": "N/A",
"complete": true,
"deployer": "Push-Deployer",
"end_time": "2023-08-09T16:12:30.1188313Z",
"id": "2a1d69d2-f3af-435c-a5e7-b2fc1b1e6c48",
"is_readonly": true,
"is_temp": false,
"last_success_end_time": "2023-08-09T16:12:30.1188313Z",
"log_url": "https://sealworkerfunction2.scm.azurewebsites.net/api/deployments/latest/log",
"message": "Created via a push deployment",
"progress": "",
"received_time": "2023-08-09T16:12:24.3388912Z",
"site_name": "sealworkerfunction2",
"start_time": "2023-08-09T16:12:26.2433316Z",
"status": 4,
"status_text": "",
"url": "https://sealworkerfunction2.scm.azurewebsites.net/api/deployments/latest"
}
我首先删除旧的构建 dist/
,然后再次构建并再次使用 zip 文件进行部署。
部署成功。
但是,删除的脚本仍然存在于azure函数门户的“代码+测试”部分中:
我可以确认新的 zip 文件已上传到 /home/data/SitePackages
文件夹中。
顺便说一句,wwwroot
文件夹是这样的:
kudu_ssh_user@6dfe9b30b25a:~/site/wwwroot$ ls -lat
total 2
-rwxrwxrwx 1 nobody nogroup 1445 Aug 4 13:35 .gitignore
drwxrwxrwx 2 nobody nogroup 0 Aug 4 06:32 .vscode
-rwxrwxrwx 1 nobody nogroup 120 Aug 3 15:59 .funcignore
drwxrwxrwx 2 nobody nogroup 0 Aug 3 06:33 .
drwxrwxrwx 2 nobody nogroup 0 Aug 3 06:33 ..
kudu_ssh_user@6dfe9b30b25a:~/site/wwwroot$
那么为什么删除的文件仍然显示?
最佳答案
Azure Function Portal:即使在新部署中删除脚本,脚本仍然存在
我在我的环境中重现了类似的情况。我部署了一个名为 “deletedfile” 的 Azure 函数,函数名称为 “test”。
我创建了 2 个文件 test2.js
和 test3.js
并进行了部署。在我的azure函数“deletedfile”中,代码+测试部分文件可见,如下所示:
但是在删除文件 test2.js
和 test3.js
后重新部署该函数后。但是,它在我的函数的代码+测试环境中不可见,如下所示:
尝试重新部署该函数。
关于Azure功能门户: script still exists even though it is deleted in the new deployment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76869592/