0

I've used New-AzureRmWebApp to create WebApp from powershell. But I don't find any cmdlet to upload package to created Azure Web App :( Looking for AzureRm cmdlet in specific.

Vidhya Sagar Reddy
  • 1,521
  • 1
  • 13
  • 25

1 Answers1

0

If you are co-admin of your subscription,you can use command Publish-AzureWebsiteProject -Name site1 -Package .\WebApplication1.zip to do that.We also can use kudu Rest API (Zip).More detail about how to get authorization please refer to another SO thread

kudu Rest Api sample code:

$website = Get-AzureWebsite -Name "WebAppSampleFtn2"
$username = $website.PublishingUsername
$password = $website.PublishingPassword
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$userAgent = "powershell/1.0"
$apiBaseUrl = "https://$($website.Name).scm.azurewebsites.net/api/zip/site/wwwroot"
$filePath = "D:\package\PackageTmp.zip"
Invoke-RestMethod -Uri $apiBaseUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -UserAgent $userAgent -Method PUT -InFile $filePath -ContentType "multipart/form-data"
Community
  • 1
  • 1
Terry Fei
  • 249
  • 1
  • 3
  • Am looking for AzureResourceManager cmdlet in specific. Publish-AzureWebsiteProject requires me to setup my subscription again – Vidhya Sagar Reddy Mar 28 '17 at 02:28
  • it looks like there is not suitable AzureRM cmdlet to upload package to create azure web app.we can use kudu Rest API (Zip) to do that. here is sample code have tested to be work. – Terry Fei Mar 28 '17 at 05:59