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.
Asked
Active
Viewed 235 times
0

Vidhya Sagar Reddy
- 1,521
- 1
- 13
- 25
-
which package are you talking about? – 4c74356b41 Mar 27 '17 at 08:47
-
I've an application package(.zip), generated by publishing web project to a physical folder. – Vidhya Sagar Reddy Mar 27 '17 at 09:23
-
According to [official documnt](https://learn.microsoft.com/en-us/powershell/resourcemanager/azurerm.websites/v2.7.0/azurerm.websites), currently we can't find AzureRM Powershell command to support upload package directly. – Tom Sun - MSFT Mar 29 '17 at 14:45
1 Answers
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"
-
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