我有一个PowerShell脚本,可以在Azure上创建一个Web应用程序。该脚本还获取我文件夹中的文件并使用FTP上传它们。我也看到文件已更新,这很棒。我的代码是Python Rest API。
我的问题是“部署”阶段没有运行。 例如,如果我使用git进行部署,则会出现自动部署,如下所示:
remote: Preparing deployment for commit id '48a4891b08'.
remote: Generating deployment script.
remote: Running deployment command...
remote: Handling python deployment.
使用ftp 不会发生并且未安装新的python包。
那么,有没有办法发信号通知要部署的网络应用?
以下是我的代码片段:
# Create a resource group
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location
# Create an App Service plan in `Free` tier.
New-AzureRmAppServicePlan -Name $webappName -Location $location -ResourceGroupName $resourceGroupName -Tier Free
# Create a web app.
New-AzureRmWebApp -Name $webappName -Location $location -AppServicePlan $webappName `
-ResourceGroupName $resourceGroupName
# Get publishing profile for the web app
[xml]$xml = (Get-AzureRmWebAppPublishingProfile -Name $webappName `
-ResourceGroupName $resourceGroupName `
-OutputFile null)
# Extract connection information from publishing profile
$username = $xml.SelectNodes("//publishProfile[@publishMethod=`"FTP`"]/@userName").value
$password = $xml.SelectNodes("//publishProfile[@publishMethod=`"FTP`"]/@userPWD").value
$url = $xml.SelectNodes("//publishProfile[@publishMethod=`"FTP`"]/@publishUrl").value
# Upload files recursively
Set-Location $appDirectory
$webclient = New-Object -TypeName System.Net.WebClient
$webclient.Credentials = New-Object System.Net.NetworkCredential($username,$password)
$files = Get-ChildItem -Path $appDirectory -Recurse | Where-Object{!($_.PSIsContainer)}
foreach ($file in $files)
{
$relativepath = (Resolve-Path -Path $file.FullName -Relative).Replace(".\", "").Replace('\', '/')
$uri = New-Object System.Uri("$url/$relativepath")
"Uploading to " + $uri.AbsoluteUri
$webclient.UploadFile($uri, $file.FullName)
}
$webclient.Dispose()