Skip to content

Commit e6c9113

Browse files
JoyerJinPan-Qi
authored andcommitted
add polling delay logic for custom code
1 parent 6bc0ddf commit e6c9113

File tree

6 files changed

+61
-26
lines changed

6 files changed

+61
-26
lines changed

src/Workloads/SapVirtualInstance.Autorest/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,3 @@
2424
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0")]
2525
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
2626
[assembly: System.CLSCompliantAttribute(false)]
27-
28-
29-
30-
31-
32-

src/Workloads/SapVirtualInstance.Autorest/custom/New-AzWorkloadsSapVirtualInstance/New-AzWorkloadsSapVirtualInstance_CreateWithJsonString.cs

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public partial class NewAzWorkloadsSapVirtualInstance_CreateWithJsonString : glo
104104
ReadOnly = false,
105105
Description = @"The name of the Virtual Instances for SAP solutions resource",
106106
SerializedName = @"sapVirtualInstanceName",
107-
PossibleTypes = new[] { typeof(string) })]
107+
PossibleTypes = new [] { typeof(string) })]
108108
[global::System.Management.Automation.Alias("SapVirtualInstanceName")]
109109
[global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category(global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.ParameterCategory.Path)]
110110
public string Name { get => this._name; set => this._name = value; }
@@ -148,7 +148,7 @@ public partial class NewAzWorkloadsSapVirtualInstance_CreateWithJsonString : glo
148148
ReadOnly = false,
149149
Description = @"The name of the resource group. The name is case insensitive.",
150150
SerializedName = @"resourceGroupName",
151-
PossibleTypes = new[] { typeof(string) })]
151+
PossibleTypes = new [] { typeof(string) })]
152152
[global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category(global::Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.ParameterCategory.Path)]
153153
public string ResourceGroupName { get => this._resourceGroupName; set => this._resourceGroupName = value; }
154154

@@ -287,11 +287,36 @@ protected override void EndProcessing()
287287
WriteError(new global::System.Management.Automation.ErrorRecord(new global::System.Exception(messageData().Message), string.Empty, global::System.Management.Automation.ErrorCategory.NotSpecified, null));
288288
return;
289289
}
290+
case Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.Events.Progress:
291+
{
292+
var data = messageData();
293+
int progress = (int)data.Value;
294+
string activityMessage, statusDescription;
295+
global::System.Management.Automation.ProgressRecordType recordType;
296+
if (progress < 100)
297+
{
298+
activityMessage = "In progress";
299+
statusDescription = "Checking operation status";
300+
recordType = System.Management.Automation.ProgressRecordType.Processing;
301+
}
302+
else
303+
{
304+
activityMessage = "Completed";
305+
statusDescription = "Completed";
306+
recordType = System.Management.Automation.ProgressRecordType.Completed;
307+
}
308+
WriteProgress(new global::System.Management.Automation.ProgressRecord(1, activityMessage, statusDescription)
309+
{
310+
PercentComplete = progress,
311+
RecordType = recordType
312+
});
313+
return ;
314+
}
290315
case Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.Events.DelayBeforePolling:
291316
{
317+
var data = messageData();
292318
if (true == MyInvocation?.BoundParameters?.ContainsKey("NoWait"))
293319
{
294-
var data = messageData();
295320
if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)
296321
{
297322
var asyncOperation = response.GetFirstHeader(@"Azure-AsyncOperation");
@@ -303,6 +328,22 @@ protected override void EndProcessing()
303328
return;
304329
}
305330
}
331+
else
332+
{
333+
if (data.ResponseMessage is System.Net.Http.HttpResponseMessage response)
334+
{
335+
int delay = (int)(response.Headers.RetryAfter?.Delta?.TotalSeconds ?? 30);
336+
WriteDebug($"Delaying {delay} seconds before polling.");
337+
for (var now = 0; now < delay; ++now)
338+
{
339+
WriteProgress(new global::System.Management.Automation.ProgressRecord(1, "In progress", "Checking operation status")
340+
{
341+
PercentComplete = now * 100 / delay
342+
});
343+
await global::System.Threading.Tasks.Task.Delay(1000, token);
344+
}
345+
}
346+
}
306347
break;
307348
}
308349
}

src/Workloads/SapVirtualInstance.Autorest/docs/Az.SapVirtualInstance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Module Name: Az.SapVirtualInstance
3-
Module Guid: ef2fac55-c936-4613-9618-a7795408b0e7
3+
Module Guid: eb2e2511-78ef-4d9c-bbb0-036cc3938af0
44
Download Help Link: https://learn.microsoft.com/powershell/module/az.sapvirtualinstance
55
Help Version: 1.0.0.0
66
Locale: en-US
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"generate_Id": "b1b4927c-1ce8-4cfd-a5ab-635f801b67b0"
2+
"generate_Id": "085e147c-e193-4ad4-bd5a-1bf8fe8b7288"
33
}

src/Workloads/Workloads.sln

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Monitors.Autorest", "Monito
2525
EndProject
2626
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SapVirtualInstance.Autorest", "SapVirtualInstance.Autorest", "{EB808B23-4039-57BF-39D0-8ACE41B9711F}"
2727
EndProject
28-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.SapVirtualInstance", "..\..\generated\Workloads\SapVirtualInstance.Autorest\Az.SapVirtualInstance.csproj", "{1AC47149-8B47-43DC-A827-124E73148902}"
28+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Az.SapVirtualInstance", "..\..\generated\Workloads\SapVirtualInstance.Autorest\Az.SapVirtualInstance.csproj", "{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}"
2929
EndProject
3030
Global
3131
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -133,18 +133,18 @@ Global
133133
{74EA2E4F-203E-47AB-8EB7-8FD701000929}.Release|x64.Build.0 = Release|Any CPU
134134
{74EA2E4F-203E-47AB-8EB7-8FD701000929}.Release|x86.ActiveCfg = Release|Any CPU
135135
{74EA2E4F-203E-47AB-8EB7-8FD701000929}.Release|x86.Build.0 = Release|Any CPU
136-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|Any CPU.Build.0 = Debug|Any CPU
138-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|x64.ActiveCfg = Debug|Any CPU
139-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|x64.Build.0 = Debug|Any CPU
140-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|x86.ActiveCfg = Debug|Any CPU
141-
{1AC47149-8B47-43DC-A827-124E73148902}.Debug|x86.Build.0 = Debug|Any CPU
142-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|Any CPU.ActiveCfg = Release|Any CPU
143-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|Any CPU.Build.0 = Release|Any CPU
144-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|x64.ActiveCfg = Release|Any CPU
145-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|x64.Build.0 = Release|Any CPU
146-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|x86.ActiveCfg = Release|Any CPU
147-
{1AC47149-8B47-43DC-A827-124E73148902}.Release|x86.Build.0 = Release|Any CPU
136+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
138+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|x64.ActiveCfg = Debug|Any CPU
139+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|x64.Build.0 = Debug|Any CPU
140+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|x86.ActiveCfg = Debug|Any CPU
141+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Debug|x86.Build.0 = Debug|Any CPU
142+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
143+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|Any CPU.Build.0 = Release|Any CPU
144+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|x64.ActiveCfg = Release|Any CPU
145+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|x64.Build.0 = Release|Any CPU
146+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|x86.ActiveCfg = Release|Any CPU
147+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7}.Release|x86.Build.0 = Release|Any CPU
148148
EndGlobalSection
149149
GlobalSection(SolutionProperties) = preSolution
150150
HideSolutionNode = FALSE
@@ -156,6 +156,6 @@ Global
156156
{21B0E1A3-B9B6-42E9-97B7-DC1A56FDBABA} = {CDFD4C75-7CF6-4B30-9A7E-D8B5D25EB75A}
157157
{84EB3D08-249C-4900-8E17-832EC2DB5494} = {CDFD4C75-7CF6-4B30-9A7E-D8B5D25EB75A}
158158
{CF8A9A95-4825-47E0-86E7-2788A2127BE1} = {CDFD4C75-7CF6-4B30-9A7E-D8B5D25EB75A}
159-
{1AC47149-8B47-43DC-A827-124E73148902} = {EB808B23-4039-57BF-39D0-8ACE41B9711F}
159+
{F4F8B31D-E0D0-4F97-BBAD-33CDA26D41F7} = {EB808B23-4039-57BF-39D0-8ACE41B9711F}
160160
EndGlobalSection
161161
EndGlobal

src/Workloads/Workloads/Az.Workloads.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 8/20/2025
6+
# Generated on: 9/5/2025
77
#
88

99
@{

0 commit comments

Comments
 (0)