public async Task CreateOrUpdateAtMgmtGroup()
        {
            //This test uses a pre-created management group.
            ManagementGroup mgmtGroup = await GetCreatedManagementGroup();

            string policyDefinitionName = Recording.GenerateAssetName("polDef-");
            ManagementGroupPolicyDefinition policyDefinition = await CreatePolicyDefinitionAtMgmtGroup(mgmtGroup, policyDefinitionName);

            string policySetDefinitionName = Recording.GenerateAssetName("polSetDef-");
            ManagementGroupPolicySetDefinition policySetDefinition = await CreatePolicySetDefinitionAtMgmtGroup(mgmtGroup, policyDefinition, policySetDefinitionName);

            Assert.AreEqual(policySetDefinitionName, policySetDefinition.Data.Name);
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await mgmtGroup.GetManagementGroupPolicySetDefinitions().CreateOrUpdateAsync(true, null, policySetDefinition.Data));
            Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await mgmtGroup.GetManagementGroupPolicySetDefinitions().CreateOrUpdateAsync(true, policySetDefinitionName, null));
        }
示例#2
0
        protected async Task <ManagementGroupPolicySetDefinition> CreatePolicySetDefinitionAtMgmtGroup(ManagementGroup mgmtGroup, ManagementGroupPolicyDefinition policyDefinition, string policySetDefinitionName)
        {
            PolicySetDefinitionData input = new PolicySetDefinitionData
            {
                DisplayName       = $"Test ${policySetDefinitionName}",
                PolicyDefinitions = { new PolicyDefinitionReference(policyDefinition.Id) }
            };
            ArmOperation <ManagementGroupPolicySetDefinition> lro = await mgmtGroup.GetManagementGroupPolicySetDefinitions().CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, input);

            return(lro.Value);
        }