Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure 如何使用powershell从远程zip文件部署functionapp_Azure_Powershell - Fatal编程技术网

Azure 如何使用powershell从远程zip文件部署functionapp

Azure 如何使用powershell从远程zip文件部署functionapp,azure,powershell,Azure,Powershell,我想使用另一个使用powershell的azure blob存储中的zip文件在azure中部署functionApp。 我试着用下面的方法 #PowerShell $username = "<deployment_user>" $password = "<deployment_password>" $filePath = "https://xxxxx.blob.core.windows.net/container/zzzz.zip" $apiUrl = "https:/

我想使用另一个使用powershell的azure blob存储中的zip文件在azure中部署functionApp。 我试着用下面的方法

#PowerShell
$username = "<deployment_user>"
$password = "<deployment_password>"
$filePath = "https://xxxxx.blob.core.windows.net/container/zzzz.zip"
$apiUrl = "https://<app_name>.scm.azurewebsites.net/api/zipdeploy"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f 
$username, $password)))
$userAgent = "powershell/1.0"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath - ContentType "multipart/form-data"
#PowerShell
$username=“”
$password=“”
$filePath=”https://xxxxx.blob.core.windows.net/container/zzzz.zip"
$apiUrl=”https://.scm.azurewebsites.net/api/zipdeploy"
$base64AuthInfo=[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(“{0}:{1}”-f
$username,$password)))
$userAgent=“powershell/1.0”
调用RestMethod-Uri$apirl-Headers@{Authorization=('Basic{0})-f$base64AuthInfo}-UserAgent$UserAgent-Method-POST-infle$filePath-ContentType“多部分/表单数据”
但是我得到了如下错误消息

调用RestMethod:找不到驱动器。名为“https”的驱动器不存在

如何从远程url文件进行部署

Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method POST -InFile $filePath - ContentType "multipart/form-data"
-填充$filePath

param需要本地文件的路径

检查文档:

使用类似于:

  • 首先,从Azure存储下载blob
  • 转换成字节流
  • 设置为请求(正文)的一部分
  • 示例代码供参考:

    $base64Image = [convert]::ToBase64String((get-content $path -encoding byte))
    

    Invoke-WebRequest-uri$uri-Method-Post-Body$base64Image-ContentType“application/base64”

    由于
    Invoke-RestMethod
    infle接受文件中的内容,因此需要先显式下载blob内容

    选项1

    $fileUrl = "https://xxxxx.blob.core.windows.net/container/zzzz.zip"
    $token = 'sp=r&st=2019-07-06T21:41:45Z&se=2019-07-07T05:41:45Z&spr=https&sv=2018-03-28&sig=9ud%2FiJ6GBccxZfyrKsZtP69lwuralu1D0QiiESa%2FXgo%3D&sr=b'
    $filePath = [System.IO.Path]::GetFileName($fileUrl)
    Invoke-WebRequest ('{0}?{1}' -f $fileUrl, $token) -OutFile $filePath  
    
    先决条件

    需要提供的不是资源Url,而是 其中包括一个SAS令牌,用于执行经过身份验证的 请求

    选项2

    通过:

    $StorageAccountName = 'yourstorageaccount'
    $StorageAccountKey = Get-AzureStorageKey -StorageAccountName $StorageAccountName
    $StorageContext = New-AzureStorageContext $StorageAccountName -StorageAccountKey $StorageAccountKey.Primary
    $FileName = 'zzzz.zip'
    $OutputPath = 'C:\Temp'
    $ContainerName  = 'yourcontainer'
    Get-AzureStorageBlobContent -Blob $FilebName -Container $ContainerName -Destination $OutputPath -Context $StorageContext