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

ReFix Set-AzPolicySetDefinition InternalServerError when the initiative is too large [#20238] #20399

Merged
merged 3 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace Microsoft.Azure.Commands.ResourceManager.Cmdlets.RestClients
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components;
Expand Down Expand Up @@ -165,7 +164,18 @@ protected async Task<HttpResponseMessage> SendRequestAsync(
{
var contentString = content == null ? string.Empty : content.ToString();
// minify JOSN payload to avoid payload too large error
contentString = Regex.Replace(contentString, @"\r\n?|\n|\t| ", String.Empty);
if (!string.IsNullOrEmpty(contentString))
{
try
{
var obj = JsonConvert.DeserializeObject(contentString);
contentString = JsonConvert.SerializeObject(obj, Formatting.None);
}
catch
{
// leave contentString as it is
}
}
using (var httpContent = new StringContent(content: contentString, encoding: Encoding.UTF8, mediaType: "application/json"))
using (var request = new HttpRequestMessage(method: httpMethod, requestUri: requestUri) { Content = httpContent })
{
Expand Down
1 change: 1 addition & 0 deletions src/Resources/Resources/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
-->

## Upcoming Release
* Fixed issue introduced in previous fix for `Set-AzPolicySetDefinition` InternalServerError when the initiative is too large [#20238], which will remove space in value.

## Version 6.5.0
* Added cmdlet `Get-AzADOrganization`
Expand Down