我在VS中创建了一个示例.net sdk应用程序。我还创建了在门户中扩展的,并使用VS中的包更新了它。最初,我在配置文件中没有虚拟网络设置,但后来我添加了它们。我能够成功地从VS发布使用发布选项。但是,当在dev op中通过发布管道触发时,部署就会失败。代码在git中心。每次签入都会触发一个构建,并从dev op中释放。错误如下所示。目标服务是门户中已经创建的天云服务扩展。在调试输出中,我看到cmd Get-AzureDeployment kgcloudservicefordevopstesting生产没有找到资源,因此脚本进入创建服务(而不是更新),这似乎会引发此问题。不过,我可以看到使用Az powershell cmd的资源。我在管道中使用部署助手。它只显示我的经典存储帐户,而不显示较新的存储帐户。我想知道我是否应该使用其他的助手,但找不到类似的东西。任何帮助都将不胜感激。
PS C:\WINDOWS\system32> Get-AzCloudService
ResourceGroupName名称定位ProvisioningState
威斯特斯
管线上的调试线路: 021-12-10T03:26:06.3881535Z ##命令组2021-12-10T03:26:07.0928109Z ##debugOperationID:'4278a00d915739b7bdd6579aef8d3191‘--> Hyak.Common.CloudException: ResourceNotFound:没有发现部署。2021-12-10T03:26:07.0968 346 Z ##debug at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task任务)2021-12-10T03:26:07.1001646 Z ##debug at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task任务) 2021-12-10T03:26:07.1033857Z ##debug at Microsoft.WindowsAzure.Management.Compute.DeploymentOperationsExtensions.GetBySlot(IDeploymentOperations操作,字符串serviceName,2021-12-10T03:26:07.1071183Z Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSMTResult at 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 ##debug at Microsoft.WindowsAzure.Commands.Utilities.Common.ServiceManagementBaseCmdlet.ExecuteClientActionNewSMTResult在d:\workspace\powershell-sign\src\ServiceManagement\Services\Commands.Utilities\Common\ServiceManagementBaseCmdlet.cs:line 1633-2021-12-10T03:26:07.1182003Z#commandNew-AzureDeployment kgcloudservicefordevopstesting 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 ##debug3:26:09 AM -开始运作:新的2021-12-10T03:26:10.2667166Z任务脚本中的##debugCaught异常。2021-12-10T03:26:10.2714719Z ##debugError记录: 2021-12-10T03:26:10.4139673Z #调试器-AzureDeployment: ConflictError:现在应该使用Azure资源管理器创建云服务(扩展支持),而不是创建云服务(经典)。在- https://aka.ms/cloudservicesretirement上了解更多信息。2021-12-10T03:26:10.4163429Z D:\a_tasks\AzureCloudPowerShellDeployment_2ca8fe15-42ea-4b26-80f1-e0738ec17e89\1.184.0\Publish-AzureCloudDeployment.ps1:115 ##debugOperationID:'0c1929d2629e3af9a9c0c70f04c5be26‘2021-12-10T03:26:10.4214192Z ##debugAt ##debugAt char:32 2021-12-10T03:26:10.4235990Z ##debug+就业=新- -ServiceName $ServiceName -Package $s .
发布于 2022-03-21 22:06:54
下面是一个用于更新现有云服务的powershell脚本(扩展支持)。我只是在Azure管道Powershell任务中弹出这个。
备注:假设CloudService已经创建和部署,因为它使用了现有的Os/Network/角色/扩展定义。还假设存储帐户存在并与Cloud位于同一资源组中。
$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"
有人可能会把它变成一个可重用的自定义任务,而不需要花费太多的精力。https://learn.microsoft.com/en-us/azure/devops/extend/develop/add-build-task?view=azure-devops
https://stackoverflow.com/questions/70300013
复制相似问题