-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Az cmdlets should allow any network operations to be timed out. #19256
Comments
Or is this what is intended with the |
You could create an issue in powershell repo: https://github.com/Azure/azure-powershell |
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure. Issue DetailsIs your feature request related to a problem? Please describe. The Azure SDK team has experienced since REST calls that never returned - even after an hour of waiting. No network app should really be without a way to cancel, and it so happens that the Azure SDKs - in all languages, but I'll focus on .NET here - have a way for apps to do that. This way, we're not blocked waiting for a network call to return even if the server is not responding correctly. Describe the solution you'd like All the track 2 SDKs take a CancellationToken as the last parameter. The track 1 SDKs should provide a similar mechanism. One thought it just to declare a Whatever the decision, you can create a using var cts = new CancellationTokenSource(timeoutInMilliseconds);
Response<KeyVaultSecret> response = client.GetSecret(secretName, cancellationToken: cts.Token); You could default to no timeout to maintain compatibility (it an integer, typically -1 means infinite). Describe alternatives you've considered Right now I'm starting a
|
So how is cancellation handled in the az CLI? Is there a default timeout? I don't see anything obvious in general or command-specific help. There's |
Azure PowerShell vs Azure CLIAz cmdlets are from Azure PowerShell, not Azure CLI. They are 2 different tools with completely different implementation mechanisms:
Network timeout vs endless pollingI don't think the timeout is regarding network, but the endless polling on async ARM operations. If an HTTP request times out, Azure CLI will retry several times and fail. If an Indeed, there is no parameter to specify the polling timeout in Azure CLI.
|
except KeyboardInterrupt: | |
self.progress_bar.stop() | |
logger.error('Long-running operation wait cancelled. %s', correlation_message) | |
raise |
You may also press Ctrl+Break to forcibly kill it (https://stackoverflow.com/questions/1364173/stopping-python-using-ctrlc):
> az group delete -n cli_test_azure_firewall_rules_with_ipgroupse4upfibqoujmdn4odvtgrbuvqqgdvwd7 --yes
# Press Ctrl+Break
^CTerminate batch job (Y/N)? y
>
Ctrl+C in Azure PowerShell
I tested with Azure PowerShell, and indeed Ctrl+C is not able to cancel it:
Remove-AzResourceGroup -name test_rg -Force
# Not responding to Ctrl+C
This has been reported at Azure/azure-powershell#14867, Azure/azure-powershell#15213.
Yes, I know they are different. I asked about the Az cmdlets internally and someone told me to open an issue here. Will close. No, Ctrl+C does not work for PowerShell cmdlets because they are not separate processes nor does PowerShell really rely on Ctrl+C cancellation. It uses jobs, which Az cmdlets do support but not correctly. The internal discussion continues. |
Is your feature request related to a problem? Please describe.
The Azure SDK team has experienced since REST calls that never returned - even after an hour of waiting. No network app should really be without a way to cancel, and it so happens that the Azure SDKs - in all languages, but I'll focus on .NET here - have a way for apps to do that. This way, we're not blocked waiting for a network call to return even if the server is not responding correctly.
Describe the solution you'd like
All the track 2 SDKs take a CancellationToken as the last parameter. The track 1 SDKs should provide a similar mechanism. One thought it just to declare a
-TimeoutSec
parameter likeInvoke-RestMethod
, though there are other options here.New-PSSessionOption
has a few parameters like-CancelTimeout
that take milliseconds.Whatever the decision, you can create a
CancellationTokenSource
to cancel our methods like so:You could default to no timeout to maintain compatibility (it an integer, typically -1 means infinite).
Describe alternatives you've considered
Right now I'm starting a
ThreadJob
(cheaper than aBackgroundJob
which creates a module and starts a new pwsh.exe process) as shown in Azure/azure-sdk-tools#1912; however, while I can stop waiting for a job, I can't kill it unless I use aBackgroundJob
and kill the process, but starting a new process for each resource to purge would be very expensive time-wise. Ideally, the cmdlets - like all network clients - should have some sort of timeout mechanism.The text was updated successfully, but these errors were encountered: