Azure网站Kudu REST API-身份验证 [英] Azure Websites Kudu REST API - Authentication

查看:109
本文介绍了Azure网站Kudu REST API-身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PowerShell通过REST API将更新的内容文件放置到Azure网站上.但是,在将凭据提供给Invoke-RestMethod -Credentials时,我将返回标准Azure登录页面的HTML.

I'm trying to use PowerShell to put an updated content file onto an Azure Website via the REST API. However, when supplying my credentials into Invoke-RestMethod -Credentials I am returned the HTML of the standard Azure login page.

如何从PowerShell中使用Kudu进行身份验证?谢谢.

How can I authenticate with Kudu from PowerShell? Thanks.

推荐答案

您可以先通过Powershell获取网站,然后使用网站上的发布凭据来调用Kudu REST API.下面的示例将获取Kudu版本.

You can first get the website via Powershell and then use the publish credentials from the website to call the Kudu REST API. The example below will get the Kudu version.

$website = Get-AzureWebsite -Name "WebsiteName"

$username = $website.PublishingUsername
$password = $website.PublishingPassword
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$apiBaseUrl = "https://$($website.Name).scm.azurewebsites.net/api"

$kuduVersion = Invoke-RestMethod -Uri "$apiBaseUrl/environment" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method GET

这篇关于Azure网站Kudu REST API-身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆