gpt4 book ai didi

azure - 将 azure 文件共享安装到 azure devops 管道的速度非常慢

转载 作者:行者123 更新时间:2023-12-02 07:03:22 37 4
gpt4 key购买 nike

目前,我需要大约一分钟才能将 azure 文件共享挂载到 azure DevOps 管道。我想,这太长了。我的管道包含安装操作的两个步骤:检索凭据和安装。

enter image description here

这就是我的管道的样子:

- task: AzureCLI@2
inputs:
azureSubscription: 'My Resource Group'
scriptType: 'ps'
scriptLocation: 'inlineScript'
inlineScript: |
(get-date).ToString('T')
$sas_expiry = (Get-Date).AddHours($(storage.sas.expiry_hours)).ToUniversalTime().ToString("yyyy-M-d'T'H:M'Z'")
echo "Getting keys..."
(get-date).ToString('T')
$key=(az storage account keys list --account-name $(storage.account) | jq '.[0].value' -r)
echo "Keys are here."
echo "##vso[task.setvariable variable=storage.key;issecret=true]$key"
(get-date).ToString('T')
$sas_key=(az storage account generate-sas --account-key $key --account-name $(storage.account) --expiry $sas_expiry --https-only --permissions acdlpruw --resource-types sco --services f --output tsv)
echo "##vso[task.setvariable variable=storage.sas.key;issecret=false]$sas_key"
(get-date).ToString('T')
displayName: Get azure file share credentials
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$connectTestResult = Test-NetConnection -ComputerName mystorage.file.core.windows.net -Port 445
if ($connectTestResult.TcpTestSucceeded) {
cmd.exe /C "cmdkey /add:`"mystorage.file.core.windows.net`" /user:`"Azure\$(storage.account)`" /pass:`"$(storage.key)`""
# Mount the drive
New-PSDrive -Name $(storage.drive) -PSProvider FileSystem -Root "$(storage.unc)" -Persist
dir z:
}
else {
Write-Error -Message "Unable to reach the Azure storage account via port 445. Check to make sure your organization or ISP is not blocking port 445, or use Azure P2S VPN, Azure S2S VPN, or Express Route to tunnel SMB traffic over a different port."
}
displayName: "Mount azure file share to Z"

...我显然添加了一些时间戳输出以便于“分析”。这是日志记录。

Starting: Get azure file share credentials
==============================================================================
Task : Azure CLI
Description : Run Azure CLI commands against an Azure subscription in a PowerShell Core/Shell script when running on Linux agent or PowerShell/Powershell Core/Batch script when running on Windows agent.
Version : 2.0.5
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-cli
==============================================================================
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" --version"
WARNING: You have 2 updates available. Consider updating your CLI installation. Instructions can be found at https://learn.microsoft.com/en-us/cli/azure/install-azure-cli
azure-cli 2.0.80 *

command-modules-nspkg 2.0.3
core 2.0.80 *
nspkg 3.0.4
telemetry 1.0.4

Extensions:
azure-devops 0.17.0

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Program Files\Common Files\AzureCliExtensionDirectory'

Python (Windows) 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 02:47:15) [MSC v.1900 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal




Please let us know how we are doing: https://aka.ms/clihats
Setting AZURE_CONFIG_DIR env variable to: d:\a\_temp\.azclitask
Setting active cloud to: AzureCloud
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" cloud set -n AzureCloud"
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" login --service-principal -u *** -p *** --tenant ***"
[
{
"cloudName": "AzureCloud",
"id": "3c8ec2e2-61cd-4554-bd9d-7e18817ef269",
"isDefault": true,
"name": "DevOps Experiments",
"state": "Enabled",
"tenantId": "***",
"user": {
"name": "***",
"type": "servicePrincipal"
}
}
]
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" account set --subscription 3c8ec2e2-61cd-4554-bd9d-7e18817ef269"
C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'd:\a\_temp\azureclitaskscript1581554138338.ps1'"
12:36:15 AM
Getting keys...
12:36:15 AM
Keys are here.
12:36:21 AM
12:36:23 AM
C:\windows\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" account clear"
Finishing: Get azure file share credentials

...第 2 步:

Starting: Mount azure file share to Z
==============================================================================
Task : PowerShell
Description : Run a PowerShell script on Linux, macOS, or Windows
Version : 2.163.1
Author : Microsoft Corporation
Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
==============================================================================
Generating script.
========================== Starting Command Output ===========================
"C:\windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'd:\a\_temp\5ebb0c88-b7df-4c27-9dd3-51c6966ba590.ps1'"

CMDKEY: Credential added successfully.

Name Used (GB) Free (GB) Provider Root CurrentLocation
---- --------- --------- -------- ---- ---------------
Z 41.84 5078.16 FileSystem \\mystorage.file.core.windows.n...

PSPath : Microsoft.PowerShell.Core\FileSystem::Z:\builds
PSParentPath : Microsoft.PowerShell.Core\FileSystem::Z:\
PSChildName : builds
PSDrive : Z
PSProvider : Microsoft.PowerShell.Core\FileSystem
PSIsContainer : True
Name : builds
FullName : Z:\builds
Parent :
Exists : True
Root : Z:\
Extension :
CreationTime : 2/9/2020 8:28:26 PM
CreationTimeUtc : 2/9/2020 8:28:26 PM
LastAccessTime : 2/9/2020 8:28:26 PM
LastAccessTimeUtc : 2/9/2020 8:28:26 PM
LastWriteTime : 2/9/2020 8:28:26 PM
LastWriteTimeUtc : 2/9/2020 8:28:26 PM
Attributes : Directory
Mode : d-----
BaseName : builds
Target :
LinkType :



Finishing: Mount azure file share to Z

所有这些都在默认的 Microsoft Azure 托管代理上运行。我该怎么做才能更快地装载文件共享?

最佳答案

检查az cli的任务日志,它实际上调用了powershell.exe来执行az cli任务中的脚本。

因此可以将powershell任务中的脚本合并到az cli任务中。

在一个任务中执行脚本应该比在两个任务中执行脚本更快。

关于azure - 将 azure 文件共享安装到 azure devops 管道的速度非常慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60199015/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com