简体   繁体   English

Azure 通过开发操作管道的云服务扩展部署失败

[英]Azure Cloud Service Extended deployment via dev ops pipeline fails

I created a sample .net sdk web api application in VS.我在 VS 中创建了一个示例 .net sdk web api 应用程序。 I also created Azure Cloud Service extended in portal and updated it with the package from VS.我还在门户中创建了 Azure 云服务扩展,并使用 VS 中的 package 对其进行了更新。 Initially, I did not have Virtual Network settings in the configuration files, but I later added them.最初,我在配置文件中没有虚拟网络设置,但后来我添加了它们。 I am able to publish successfully from VS using publish option.我能够使用发布选项从 VS 成功发布。 However, the deployment fails when triggered via release pipeline in dev ops.但是,当通过开发操作中的发布管道触发时,部署会失败。 The code is in git hub.代码在 git 中心。 Every check in will trigger a build and release from dev ops.每次签入都会触发开发人员的构建和发布。 The error is shown below.错误如下所示。 The target service is the azure cloud service extended that was already created in the portal.目标服务是已经在门户中创建的 azure 云服务扩展。 In the debug output, I see that the cmd Get-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Slot Production did not find the resource and hence the script goes into creation of the service (rather than update) which seems to throw this issue.在调试 output 中,我看到 cmd Get-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Slot Production 没有找到资源,因此脚本开始创建服务(而不是更新),这似乎引发了这个问题。 I can see the resource using Az powershell cmd, however.但是,我可以使用 Az powershell cmd 查看资源。 I am using Azure Cloud Service deployment helper in the pipeline.我在管道中使用 Azure 云服务部署助手。 It only shows my classic storage account but not newer storage accounts.它只显示我的经典存储帐户,但不显示较新的存储帐户。 I am wondering if I should be using some other helper but can't find anything similar.我想知道我是否应该使用其他帮助者但找不到类似的东西。 Any help would be appreciated.任何帮助,将不胜感激。

PS C:\WINDOWS\system32> Get-AzCloudService PS C:\WINDOWS\system32> Get-AzCloudService

ResourceGroupName Name Location ProvisioningState ResourceGroupName 名称位置 ProvisioningState


WESTUS kgcloudservicefordevopstesting westus Succeeded WESTUS kgcloudservicefordevops测试westus成功

Debug lines from pipeline: 021-12-10T03:26:06.3881535Z ##[command]Get-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Slot Production -ErrorAction SilentlyContinue -ErrorVariable azureDeploymentError 2021-12-10T03:26:06.4024994Z ##[debug]3:26:06 AM - Begin Operation: Get-AzureDeployment 2021-12-10T03:26:06.9384711Z ##[debug]3:26:06 AM - Completed Operation: Get-AzureDeployment 2021-12-10T03:26:07.0894610Z ##[debug]Microsoft.WindowsAzure.Commands.Common.ComputeCloudException: ResourceNotFound: No deployments were found.来自管道的调试行: 021-12-10T03:26:06.3881535Z ##[command]Get-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Slot Production -ErrorAction SilentlyContinue -ErrorVariable azureDeploymentError 2021-12-10T03:26:06.4024994Z ##[debug] 3:26:06 AM - 开始操作:Get-AzureDeployment 2021-12-10T03:26:06.9384711Z ##[debug]3:26:06 AM - 完成操作:Get-AzureDeployment 2021-12-10T03:26:07.0894610 Z ##[调试]Microsoft.WindowsAzure.Commands.Common.ComputeCloudException: ResourceNotFound: 未找到部署。 2021-12-10T03:26:07.0928109Z ##[debug]OperationID: '4278a00d915739b7bdd6579aef8d3191' ---> Hyak.Common.CloudException: ResourceNotFound: No deployments were found. 2021-12-10T03:26:07.0928109Z ##[debug]OperationID: '4278a00d915739b7bdd6579aef8d3191' ---> Hyak.Common.CloudException: ResourceNotFound: 未找到部署。 2021-12-10T03:26:07.0968346Z ##[debug] at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 2021-12-10T03:26:07.1001646Z ##[debug] at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) 2021-12-10T03:26:07.1033857Z ##[debug] at Microsoft.WindowsAzure.Management.Compute.DeploymentOperationsExtensions.GetBySlot(IDeploymentOperations operations, String serviceName, DeploymentSlot deploymentSlot) 2021-12-10T03:26:07.1071183Z ##[debug] at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSM[TResult](Object input, String operationDescription, Func 1 action, Func 3 contextFactory) in d:\workspace\powershell-sign\src\ServiceManagement\Services\Commands.Utilities\Common\ServiceManagementBaseCmdlet.cs:line 152 2021-12-10T03:26:07.1097514Z ##[debug] --- End of inner exception stack trace --- 2021-12-10T03:26:07.1126379Z ##[debug] at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementB 2021-12-10T03:26:07.0968346Z ##[调试] 在 Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 2021-12-10T03:26:07.1001646Z ##[调试] 在 Microsoft.Runtime.CompilerServices .TaskAwaiter.HandleNonSuccess(任务任务)2021-12-10T03:26:07.1033857Z ##[调试] 在 Microsoft.WindowsAzure.Management.Compute.DeploymentOperationsExtensions.GetBySlot(IDeploymentOperations 操作,字符串服务名称,DeploymentSlot deploymentSlot)2021-12-10T03 :26:07.1071183Z ##[调试] 在 Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSM[TResult](对象输入,字符串操作描述,Func 1 action, Func 3 contextFactory)在 d:\workspace\powershell- sign\src\ServiceManagement\Services\Commands.Utilities\Common\ServiceManagementBaseCmdlet.cs:line 152 2021-12-10T03:26:07.1097514Z ##[debug] --- 内部异常堆栈跟踪结束 --- 2021-12 -10T03:26:07.1126379Z ##[调试] 在 Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementB aseCmdlet.ExecuteClientActionNewSM[TResult](Object input, String operationDescription, Func 1 action, Func 3 contextFactory) in d:\workspace\powershell-sign\src\ServiceManagement\Services\Commands.Utilities\Common\ServiceManagementBaseCmdlet.cs:line 163 2021-12-10T03:26:07.1182003Z ##[command]New-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Package D:\a\r1\a_kganesan1.MyCloudServiceExtended\drop\s\AzureCloudService1\AzureCloudService1\bin\Release\app.publish\AzureCloudService1.cspkg -Configuration D:\a\r1\a_kganesan1.MyCloudServiceExtended\drop\s\AzureCloudService1\AzureCloudService1\bin\Release\ServiceConfiguration.cscfg -Slot Production -Label 20211210.7 12/10/2021 03:26:06 -ExtensionConfiguration 2021-12-10T03:26:09.7380161Z ##[debug]3:26:09 AM - Begin Operation: New-AzureDeployment 2021-12-10T03:26:10.2564315Z ##[debug]Leaving D:\a_tasks\AzureCloudPowerShellDeployment_2ca8fe15-42ea-4b26-80f1-e0738ec17e89\1.184.0\Publish-AzureCloudDeployment.ps1. d:\workspace\powershell-sign\src\ServiceManagement\Services\Commands.Utilities\Common\ServiceManagementBaseCmdlet.cs:line 163 2021 中的 aseCmdlet.ExecuteClientActionNewSM[TResult](Object input, String operationDescription, Func 1 action, Func 3 contextFactory) -12-10T03:26:07.1182003Z ##[command]New-AzureDeployment -ServiceName kgcloudservicefordevopstesting -Package D:\a\r1\a_kganesan1.MyCloudServiceExtended\drop\s\AzureCloudService1\AzureCloudService1\bin\Release\app.publish\AzureCloudService1 .cspkg -Configuration D:\a\r1\a_kganesan1.MyCloudServiceExtended\drop\s\AzureCloudService1\AzureCloudService1\bin\Release\ServiceConfiguration.cscfg -Slot Production -Label 20211210.7 12/10/2021 03:26:06 -ExtensionConfiguration 2021- 12-10T03:26:09.7380161Z ##[调试]3:26:09 AM - 开始操作:New-AzureDeployment 2021-12-10T03:26:10.2564315Z ##[调试]离开 D:\a_tasks\AzureCloudPowerShellDeployment_2ca8fe15-42ea -4b26-80f1-e0738ec17e89\1.184.0\Publish-AzureCloudDeployment.ps1。 2021-12-10T03:26:10.2667166Z ##[debug]Caught exception from task script. 2021-12-10T03:26:10.2667166Z ##[调试]从任务脚本捕获异常。 2021-12-10T03:26:10.2714719Z ##[debug]Error record: 2021-12-10T03:26:10.4139673Z ##[debug]New-AzureDeployment: ConflictError: Instead of creating Cloud Services (classic), you should now create Cloud Services (extended support) using Azure Resource Manager. 2021-12-10T03:26:10.2714719Z ##[debug]错误记录:2021-12-10T03:26:10.4139673Z ##[debug]New-AzureDeployment: ConflictError: 而不是创建云服务(经典),你应该现在使用 Azure 资源管理器创建云服务(扩展支持)。 Learn more at - https://aka.ms/cloudservicesretirement .https://aka.ms/cloudservicesretirement了解更多信息。 2021-12-10T03:26:10.4163429Z ##[debug]OperationID: '0c1929d2629e3af9a9c0c70f04c5be26' 2021-12-10T03:26:10.4214192Z ##[debug]At D:\a_tasks\AzureCloudPowerShellDeployment_2ca8fe15-42ea-4b26-80f1-e0738ec17e89\1.184.0\Publish-AzureCloudDeployment.ps1:115 char:32 2021-12-10T03:26:10.4235990Z ##[debug]+... eployment = New-AzureDeployment -ServiceName $ServiceName -Package $s... 2021-12-10T03:26:10.4163429Z ##[debug]OperationID: '0c1929d2629e3af9a9c0c70f04c5be26' 2021-12-10T03:26:10.4214192Z ##[debug]At D:\a_tasks\AzureCloudPowerShellDeployment_2ca8fe15-42ea-4b26-80f1-e0738ec17e89 \1.184.0\Publish-AzureCloudDeployment.ps1:115 char:32 2021-12-10T03:26:10.4235990Z ##[debug]+... 部署 = New-AzureDeployment -ServiceName $ServiceName -Package $s...

Here's a powershell script I use for updating an existing Cloud Service (Extended Support).这是我用于更新现有云服务(扩展支持)的 powershell 脚本。 I just pop this in an Azure Pipelines Powershell Task.我只是在 Azure 管道 Powershell 任务中弹出它。

Note : Assumes the CloudService has already been created and deployed as it uses the existing Os/Network/Role/Extension definitions.注意:假设 CloudService 已经创建并部署,因为它使用现有的 Os/Network/Role/Extension 定义。 Also assumes the storage account exists and lives in the same resource group as the Cloud Service.还假设存储帐户存在并且与云服务位于同一资源组中。

$cloudServiceName = "<Name of an existing Cloud Service Extended Support service>"
$resourceGroupName = "<Name of the resource group containing the Cloud Service>"
$storageAccountName = "<Name of a storage account where temporary deployment files are stored>"
$storageContainerName = "<Name of the storage container where temporary deployment files are stored>"

$buildArtifactsPath = "<Path to build artifacts downloaded by Pipeline>"
$configName = "<File name of cloud service config file *.cscfg>"
$packageName = "<File name of cloud service package file *.cspkg>"


Write-Host "Finding existing service $cloudServiceName in Resource Group $resourceGroupName"

$svc = Get-AzCloudService -ResourceGroup $resourceGroupName -CloudServiceName $cloudServiceName
if (!$svc)
{   
    throw "Failed to find existing cloud service $cloudServiceName"
}


Write-Host "Checking if storage account $storageAccountName exists"

$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName -ErrorAction SilentlyContinue
if (!$storageAccount)
{
    throw "Failed to find existing storage account $storageAccountName"
}

Write-Host "Checking if storage container $storageContainerName exists"
$container = Get-AzStorageContainer -Name $storageContainerName -Context $storageAccount.Context -ErrorAction SilentlyContinue

if (!$container)
{
    Write-Host "Storage account container not found. Creating container $storageContainerName"
    $container = New-AzStorageContainer -Name $storageContainerName -Context $storageAccount.Context -Permission Off 
}


$tokenStartTime = Get-Date 
$tokenEndTime = $tokenStartTime.AddYears(1) 


Write-Host "Uploading service configuration file to blob storage"

$cscfgBlob = Set-AzStorageBlobContent -File "$(buildArtifactsPath)/$(configName)" -Container $storageContainerName -Blob "cloudservice.cscfg" -Context $storageAccount.Context -Force
$cscfgToken = New-AzStorageBlobSASToken -Container $storageContainerName -Blob $cscfgBlob.Name -Permission r -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context 
$cscfgUrl = $cscfgBlob.ICloudBlob.Uri.AbsoluteUri + $cscfgToken 

Write-Host "Service configuration uploaded."

Write-Host "Uploading service package file to blob storage"

$cspkgBlob = Set-AzStorageBlobContent -File "$(buildArtifactsPath)/$(packageName)" -Container $storageContainerName -Blob "cloudservice.cspkg" -Context $storageAccount.Context -Force
$cspkgToken = New-AzStorageBlobSASToken -Container $storageContainerName -Blob $cspkgBlob.Name -Permission r -StartTime $tokenStartTime -ExpiryTime $tokenEndTime -Context $storageAccount.Context 
$cspkgUrl = $cspkgBlob.ICloudBlob.Uri.AbsoluteUri + $cspkgToken 

Write-Host "Service package uploaded."


Write-Host "Updating existing service $cloudServiceName with new configuration and executable package"


New-AzCloudService `
-Name $svc.Name `
-ResourceGroupName $svc.ResourceGroupName `
-Location $svc.Location `
-ConfigurationUrl $cscfgUrl `
-PackageUrl $cspkgUrl `
-UpgradeMode Auto `
-RoleProfile $svc.RoleProfile `
-NetworkProfile $svc.NetworkProfile `
-OSProfile $svc.OSProfile `
-ExtensionProfile $svc.ExtensionProfile `
-Tag @{"DeploymentLabel" = "$(Build.BuildNumber)"}


Write-Host "Cloud Service Updated"

Someone could probably turn this into a reusable custom task without too much effort.有人可能会毫不费力地将它变成可重用的自定义任务。 https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops

Microsoft is retiring Cloud Services (Classic) as described at https://aka.ms/cloudservicesretirement .https://aka.ms/cloudservicesretirement中所述,Microsoft 将停用云服务(经典)。

As part of that retirement they seem to have recently blocked deploying to newly-created Cloud Services (Classic) instances.作为退休的一部分,他们最近似乎阻止了部署到新创建的云服务(经典)实例。

I attempted to deploy a Cloud Service via Visual Studio as you mentioned, and was able to do it via Right-Click -> "Publish (Extended Support)", but not via Right-Click -> "Publish".正如您所提到的,我尝试通过 Visual Studio 部署云服务,并且能够通过右键单击 ->“发布(扩展支持)”来实现,但不能通过右键单击 ->“发布”来实现。

This is because the Extended Support option creates a different kind of Cloud Service which will be supported for the longer term.这是因为扩展支持选项创建了一种不同类型的云服务,该服务将得到长期支持。 The "Publish" option creates a Classic cloud service. “发布”选项创建经典云服务。

I think the summary is: you can no longer create a Classic cloud service and deploy to it;我认为总结是:你不能再创建一个Classic云服务并部署到它; if you're building a new Cloud Service, you should use the "Cloud Services (Extended Support)" option instead, described here in the Azure doco.如果您正在构建新的云服务,则应使用“云服务(扩展支持)”选项, Azure 文档中所述。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法更新 Azure Cloud Service Extended Support via Azure Powershell 任务 - Unable to update Azure Cloud Service Extended Support via Azure Powershell Task Elasticsearch 到 BigQuery 管道部署在云数据融合实例上失败 - Elasticsearch to BigQuery pipeline deployment fails on cloud data fusion instance Azure 应用服务 - Kudu 部署失败“缺少作曲家可执行文件” - Azure App Service - Kudu deployment fails "Missing composer executable" Azure 管道发布管道:ARM 模板部署:资源组 scope 失败,错误代码:部署失败” - Azure pipeline Release pipeline: ARM Template deployment: Resource Group scope fails with ,,Error code: DeploymentFailed" 将对 azure 开发操作存储库的访问限制为特定的 IP 地址 - Limit access to an azure dev-ops repository to specific IP addresses 在 Azure Dev Ops 中安装并运行 go package 任务 - Install and run go package task in Azure Dev Ops Django 应用程序与 Azure AD 帐户身份提供商部署到 Azure Web 应用程序服务失败 - Django app with Azure AD account identity provider deployment to Azure Web app service fails 使用 oData 从 Azure 到 select Dev Ops Project all open tickets and their children - Using oData to select from Azure Dev Ops Project all open tickets and their children Quarkus 部署到 Google Cloud App 引擎失败 - Quarkus deployment to Google Cloud App engine fails 如何从 node.js package.json 文件克隆 Azure Dev Ops 存储库? - How to clone a Azure Dev Ops repo from node.js package.json file?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM