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

[AAD] az ad ds create/update/list/show/delete: Support DomainService #2842

Merged
merged 16 commits into from
Feb 4, 2021

Conversation

evelyn-ys
Copy link
Member

@evelyn-ys evelyn-ys commented Dec 28, 2020

New command module: az ad ds support management for AAD.DomainService
Commands:

  • az ad ds create
  • az ad ds update
  • az ad ds list
  • az ad ds show
  • az ad ds delete

reference: AAD RP Speclet


This checklist is used to make sure that common guidelines for a pull request are followed.

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally?

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your PR is merged into master branch, a new PR will be created to update src/index.json automatically.
The precondition is to put your code inside this repo and upgrade the version in the PR but do not modify src/index.json.

@evelyn-ys evelyn-ys self-assigned this Dec 28, 2020
@yonzhan yonzhan added this to the S180 milestone Dec 28, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Dec 28, 2020

AAD

@evelyn-ys evelyn-ys changed the title [AAD] DomainService support [AAD] az ad ds create/update/list/show/delete: Support DomainService Dec 28, 2020
Comment on lines +14 to +21
az ad ds create --domain "TestDomainService.com" --ntlm-v1 "Enabled" --sync-ntlm-passwords "Enabled" \
--tls-v1 "Disabled" --filtered-sync "Enabled" --external-access "Enabled" --ldaps "Enabled" \
--pfx-certificate "MIIDPDCCAiSgAwIBAgIQQUI9P6tq2p9OFIJa7DLNvTANBgkqhkiG9w0BAQsFADAgMR4w..." \
--pfx-certificate-password "<pfxCertificatePassword>" \
--additional-recipients "jicha@microsoft.com" "caalmont@microsoft.com" --notify-dc-admins "Enabled" \
--notify-global-admins "Enabled" \
--replica-sets location="West US" subnet-id="/subscriptions/1639790a-76a2-4ac4-98d9-8562f5dfcb4d/resourceGroups/TestNetworkResourceGroup/providers/Microsoft.Network/virtualNetworks/TestVnetWUS/subnets/TestSubnetWUS" \
--name "TestDomainService.com" --resource-group "TestResourceGroup"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as #2817 (comment)

Backward slash \ is only supported by Linux Bash, we usually don't include \ in examples.

However, you can break lines without \ and add a comment to tell the user line breaks are added for legibility only, like

https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code

// Line breaks for legibility only

https://login.microsoftonline.com/{tenant}/oauth2/v2.0/authorize?
client_id=6731de76-14a6-49ae-97bc-6eba6914391e
&response_type=code
&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F
&response_mode=query
&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2Fmail.read
&state=12345
&code_challenge=YTFjNjI1OWYzMzA3MTI4ZDY2Njg5M2RkNmVjNDE5YmEyZGRhOGYyM2IzNjdmZWFhMTQ1ODg3NDcxY2Nl
&code_challenge_method=S256

So this command can be written as

az ad ds create --domain "TestDomainService.com" --ntlm-v1 "Enabled" --sync-ntlm-passwords "Enabled"
                --tls-v1 "Disabled" --filtered-sync "Enabled" --external-access "Enabled" --ldaps "Enabled"
                ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen

```

### Included Features ###
#### ad ds ####
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can explain what ds is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen

Comment on lines +15 to +18
helps['ad ds'] = """
type: group
short-summary: Manage domain service with ad
"""
Copy link
Member

@jiasli jiasli Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are redundant indents, against CLI convention, like

https://github.com/Azure/azure-cli/blob/84e0e45de5f99936ca5b933493fd6234dbf648ae/src/azure-cli/azure/cli/command_modules/vm/_help.py#L65-L73

helps['disk delete'] = """
type: command
short-summary: Delete a managed disk.
examples:
  - name: Delete a managed disk. (autogenerated)
    text: |
        az disk delete --name MyManagedDisk --resource-group MyResourceGroup
    crafted: true
"""
Suggested change
helps['ad ds'] = """
type: group
short-summary: Manage domain service with ad
"""
helps['ad ds'] = """
type: group
short-summary: Manage domain service with ad
"""

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refined in manual/_help.py


helps['ad ds'] = """
type: group
short-summary: Manage domain service with ad
Copy link
Member

@jiasli jiasli Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short-summary should usually ends with a period (.), like

https://github.com/Azure/azure-cli/blob/84e0e45de5f99936ca5b933493fd6234dbf648ae/src/azure-cli/azure/cli/command_modules/vm/_help.py#L67

short-summary: Delete a managed disk.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the description is not easy to understand with ad.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refined in manual/_help.py

FAILED = "failed"


def try_manual(func):
Copy link
Member

@jiasli jiasli Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The meaning of this try_manual is unclear to me as someone who is not familiar with the code. Also, shouldn't it be a general method that appears in the centralized test framework, instead of individual modules/extensions?

Copy link
Member Author

@evelyn-ys evelyn-ys Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen aimed to use manual code overwrite generated code

KEY_VNET_NIC = 'nic'


class VirtualNetworkPreparer(NoTrafficRecordingPreparer, SingleValueReplacer):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used? I can't seem to find any usage of VirtualNetworkPreparer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto-generated by CodeGen. I didn't use it but keep it because it will always be generated. No need to delete every time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@changlong-liu could we remove these preparer and import from azure cli core module?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes @Juliehzl , we are refactoring the test preparers codegen.

Hi @evelyn-ys , In latest autorest.az the preparers.py is supposed to be generated only when has some reference for it. Please help to send me the swagger branch to have further check if it generated even have no usage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yonzhan yonzhan modified the milestones: S180, S181 Jan 6, 2021
Copy link
Contributor

@Juliehzl Juliehzl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current az ad command group has description Manage Azure Active Directory Graph entities needed for Role Based Access Control. It seems that your command group is not for az ad from the description.

@@ -0,0 +1,3 @@
{
"azext.minCliCoreVersion": "2.15.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not in preview or experimental?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

az ad is stable. az ad ds is marked as preview in command.py

Comment on lines +54 to +55
location: Virtual network location
subnet-id: The name of the virtual network that Domain Services will be deployed on. The id of the subnet \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both of them are required?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Copy link
Contributor

@Juliehzl Juliehzl Feb 3, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. You could consider add [required] in the description for them. But should the location be the location for subnet?

@yonzhan yonzhan modified the milestones: S181, S182 Jan 26, 2021
@evelyn-ys
Copy link
Member Author

Current az ad command group has description Manage Azure Active Directory Graph entities needed for Role Based Access Control. It seems that your command group is not for az ad from the description.

Refined in manual/_help.py

@evelyn-ys evelyn-ys requested a review from Juliehzl January 28, 2021 05:19
@evelyn-ys
Copy link
Member Author

@Juliehzl I have modified according to your comments, could you pls review again? Thanks a lot!

@evelyn-ys evelyn-ys merged commit 2415c3b into Azure:master Feb 4, 2021
@jiasli
Copy link
Member

jiasli commented Jan 5, 2024

Current az ad command group has description Manage Azure Active Directory Graph entities needed for Role Based Access Control. It seems that your command group is not for az ad from the description.

Refined in manual/_help.py

Even though the help message has been updated:

helps['ad'] = """
type: group
short-summary: Manage Azure Active Directory related entities and resources.
"""

this design of putting az ad ds under az ds is still against the purpose of az ad which is designed to be a pure data-plane command group for calling AD Graph/Microsoft Graph. Because of this, in main Azure CLI, the global argument _subscription is ignored for az ad:

https://github.com/Azure/azure-cli/blob/e8efb791ea2f0ba5e4f172b26f75725fd8aa8079/src/azure-cli/azure/cli/command_modules/role/_params.py#L25-L26

    with self.argument_context('ad') as c:
        c.ignore('_subscription')  # hide global subscription param

However, apparently, az ad ds is a mgmt-plane command group calling Microsoft.AAD Resource Provider:

list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.AAD/domainServices'} # type: ignore

This means the global argument _subscription shouldn't be ignored for az ad ds.

If a specific command such as az ad ds -h is run, the core is smart enough to filter the command loader based on the command name and only load what is needed:

https://github.com/Azure/azure-cli/blob/7a4d03f077151be8fc312c9ce82febd1dda118cb/src/azure-cli-core/azure/cli/core/__init__.py#L499

            command_loaders = self.cmd_to_loader_map.get(command, None)

In such case, only azext_ad.DomainServicesResourceProviderCommandsLoader is loaded and azure.cli.command_modules.role.RoleCommandsLoader will be skipped. _subscription won't be ignored and will still appear in the in-tool help.

However, in the reference doc generation pipeline, both command loaders will be loaded. If azure.cli.command_modules.role.RoleCommandsLoader is load first, when azext_ad.DomainServicesResourceProviderCommandsLoader is loaded, _subscription will be ignored for az ad ds.

See Azure/azure-cli#27296 (comment) for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants