Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #13763- webapp:Increased timout to 300000 MS for Publish-AzWebApp cmdlet #13894

Merged
merged 18 commits into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Websites/Websites/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Intorduced an option to give custom timeout for `Publish-AzWebApp`
Kotasudhakarreddy marked this conversation as resolved.
Show resolved Hide resolved

## Version 2.2.0
* Added support for App Service Managed certificates
Expand Down
14 changes: 14 additions & 0 deletions src/Websites/Websites/Cmdlets/WebApps/PublishAzureWebApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class PublishAzureWebAppCmdlet : WebAppOptionalSlotBaseCmdlet
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Sets the timespan in Milliseconds to wait before the request times out.")]
Kotasudhakarreddy marked this conversation as resolved.
Show resolved Hide resolved
public double Timeout { get; set; }
Kotasudhakarreddy marked this conversation as resolved.
Show resolved Hide resolved

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down Expand Up @@ -72,6 +75,17 @@ public override void ExecuteCmdlet()
using (var s = File.OpenRead(ArchivePath))
{
HttpClient client = new HttpClient();
if (Timeout != 0)
Kotasudhakarreddy marked this conversation as resolved.
Show resolved Hide resolved
//The default value should be greater than default 100,000 milliseconds(100 seconds).
if (Timeout > 100000)
{
// Considering the deployment of large packages the default time(150 seconds) is not sufficient. So increased the timeout based on user choice.
client.Timeout = TimeSpan.FromMilliseconds(Timeout);
}
else
{
throw new ValidationMetadataException("Minimum value to set for the timeout is 100,000 milliseconds.");
}
var byteArray = Encoding.ASCII.GetBytes(user.PublishingUserName + ":" + user.PublishingPassword);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
HttpContent fileContent = new StreamContent(s);
Expand Down
23 changes: 23 additions & 0 deletions src/Websites/Websites/help/Publish-AzWebApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ PS C:\> Publish-AzWebApp -WebApp $app -ArchivePath C:\project\app.zip -Force

Uploads the contents of java_app.jar to the web app named ContosoApp belonging to the resource group ContosoRG.

### Example 6
```powershell
PS C:\> $app = Get-AzWebApp -ResourceGroupName ContosoRG -Name ContosoApp
PS C:\> Publish-AzWebApp -WebApp $app -ArchivePath C:\project\app.zip -Timeout 300000 -Force
```

Uploads the contents of java_app.jar to the web app named ContosoApp belonging to the resource group ContosoRG. User can Sets the timespan in Milliseconds to wait before the request times out.

## PARAMETERS

### -ArchivePath
Expand Down Expand Up @@ -171,6 +179,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Timeout
Sets the timespan in Milliseconds to wait before the request times out.

```yaml
Type: System.Double
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WebApp
The web app object

Expand Down