MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.26k stars 21.43k forks source link

Examples for the 'Replace' function #10957

Closed davegreen closed 5 years ago

davegreen commented 6 years ago

There are no examples that use the regex functionality of the 'Replace' function, which is proving a real problem for me to use these functions. I have an expression I believe should work, but I can't figure out based on the documentation what the function call should look like to take an attribute, regex, then pull that selection or group out as the data to write to the destination attribute.

Perhaps providing a way to test these functions using a fixed input and the expression or functions users have written, as otherwise (as far as I know), can only be tested in the product (which is not ideal).

If anyone knows of a way to test these expressions outside of using them in the 'Microsoft Azure Active Directory Connect Provisioning Agent' tool, i'd be incredibly grateful!

Thanks, Dave


Document details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

MohitGargMSFT commented 6 years ago

@davegreen Thanks for your feedback! We will investigate and update as appropriate.

SaurabhSharma-MSFT commented 6 years ago

@davegreen You can try using regex validation tools like RegEx Toolkit , however, I am assigning this to content author to investigate and add regex examples for REPLACE function in current documentation.

davegreen commented 6 years ago

Thank you for that, much appreciated 👍

rogereriksen commented 6 years ago

Trying to write an expression to get AppRoleAssignment value/type/displayname. Default attribute mapping for approleassignment gives a pretty long XML. Do you have any examples?

barbkess commented 6 years ago

@davegreen : Thanks for asking. I am talking to the product team to see if there is an example we can provide.

barbkess commented 6 years ago

@davegreen: https://regexr.com Is an online tool for testing regular expressions that also contains a lot of other useful help with using regex.

davegreen commented 6 years ago

@barbkess Thank you for the info, but my request was not about the use of the regular expression itself, it was more about the specific syntax and examples of the replace function itself that goes around the regular expression. I have some ideas of the syntax and structure, but it is very helpful to have a reference on some working examples, especially since examples exist for the other functions.

As an example, one of my issues is around the empty parameter pieces and whether they are needed or not, it's difficult to know without trying it. I believe the following example should use the replace to remove the first word (potentially with symbols), plus space, then take the resulting string for the capture group 'string' for the transformed attribute value.

Replace([MyAttribute], , "(?:^\S*\s)(?<string>.*$)", string, , , )

I'd like to be able to understand what should be the outcome with a reasonable probability and not just trying many different syntax variations until it works.

barbkess commented 6 years ago

@davegreen : I created a work item to work on providing the examples you are asking for. I added the work item to our backlog.

R0chen commented 6 years ago

I have an question / issue: When we setup provisioning from Workday to AD with the default mappings, AD accounts get provisioned. But even then there are failures in the activity "Synchronization rule action" in the audit logs.

This is the summary error: Activity Status Status : Failure Reason : Failed to process Worker '21431' (see details for more information); Error: We will retry this operation on the next synchronization attempt.

This is are the details error: Additional Details ErrorCode : UnSpecified EventName : EntrySynchronizationError JoiningProperty : 21431 SourceAnchor : 1f8ff0a1f91410f6cb260e1be5fe0b91

How can we troubleshoot which failure is accuring? This is quite a big issue, cause if we add mappings, they sometimes work and sometimes do not (especially expressions). It needs to be very clear on which rule or mapping the failture happens. Can someone please help us out ?

davegreen commented 6 years ago

@R0chen - This is something I have also run into a lot with the Workday to AD connection over the last few months. From what I have seen, lookup attributes (like manager) generally cause the difficult to diagnose errors like this. I haven't used a lot of expressions as it's sometimes hard to tell whether they are working as I expect for exactly the reasons you describe (leading to my request for some additional documentation for usage).

It's gotten better somewhat recently and improvements have been made, but at the moment the sync isn't something I can use in production in a reliable way, unless I limit the synced attributes to standard text only, which is much less useful. At the moment I use a set of PowerShell scripts I've written to query the Workday API and make the changes to AD without this tool. Hopefully this tool will become more reliable and useful over time.

R0chen commented 6 years ago

Hi @davegreen,

thank for this info. I will ask my MS connections related to the AAD program also about this behavior and including the fact that I am not the only one experiencing this....

DareToAsk: my PowerShell capabilities are not advanced. Is it possible to share the part how to query the Workday API?

Thank you in advance, Rochen

davegreen commented 6 years ago

@R0chen - Happy to help! I have had a chat recently to a product manager that's given me some hope. Good luck!

Of course, always dare to ask! I've put together a quick blog post together to illustrate this. You can find the post here. I'm using a Workday system integration user account set up the same as I use for the MS agent, the rights it's given should be correct if you followed the guide here.

R0chen commented 6 years ago

thx Dave. Appreciate it. We are looking to the function so we at least have a Plan B :-) But I really hope this is not needed.

barbkess commented 6 years ago

@saurabhsensharma : Please assign to @asmalser-msft .

barbkess commented 6 years ago

@SaurabhSharma-MSFT : Please assign to @asmalser-msft. Sorry, I had the wrong Saurabh in the previous comment.

SaurabhSharma-MSFT commented 6 years ago

@barbkess No problem. It is done.

Wicaeed commented 5 years ago

@davegreen Did you ever get the help you needed from MSFT in actually testing how the rules you have are trying to write will function on actual Workday data?

I'm somewhat in the same position, being a noob to the transform rules (but not regex in general), so I'm having trouble visualizing how changes in a transform rule will impact the fields I am trying to populate.

davegreen commented 5 years ago

@Wicaeed Unfortunately not. I ended up writing my own end to end sync solution since I also needed to support fields that the MS tool doesn't manage or support (thumbnail photo and some custom data).

At the time the MS solution was very unstable so it made sense from an organisational standpoint, however things are apparently better now.

I had some ideas on what the right values would be that I could have tested in a test environment, I'll see if I can dig these out for you, along with how I think it works.

asmalser-msft commented 5 years ago

Hi folks, we added a regex example for the Replace() function titled "Replace characters using a regular expression" in the doc. Please let us know if that is satisfactory, thanks!