Azure Functions to generate unique identifiers

Azure Functions to generate unique identifiers

There are so many scenarios that I faced in more than 18 years doing integration that required me to generate a unique id that I don’t know how to start explaining all of them. Unique identifiers are handy when an automation process needs to generate a unique reference “number” to identify an object or entity like a Customer account, a document id, and so on. Most of the time, we use GUIDs, which stands for a globally unique identifier, and it is usually a 128-bit text string that represents an identification (ID) that is unlikely ever to repeat or create a collision to address these scenarios unless requirements don’t allow us to use a GUID.

This is a list of 4 Functions that will allow you to generate unique identifiers:

  • GUID Generator: This function has the same capabilities available on the Online GUID / UUID Generator: https://guidgenerator.com/online-guid-generator.aspx.
  • Tickets Short GUID Generator: Calculate the uniqueId using the provided year.
  • Youtube-like GUID Generator: Function to generate a short GUID like in YouTube (N7Et6c9nL9w).
  • Tiny Id Generator: Another way that I used in the past to generate a tiny identifier.

GUID Generator Function

As mentioned above, this function has the same capabilities as the Online GUID / UUID Generator: https://guidgenerator.com/online-guid-generator.aspx. It accepts 3 optional query parameters:

  • useHyphen: accepts the values true or false to decide if you want to generate a guide separated with hyphens.
    • The default value is true.
  • useUppercase: accepts the values true or false to decide if you want to convert the GUID to upper case.
    • The default value is false.
  • useBraces: accepts the values true or false to decide if you want to generate a guide between braces.
    • The default value is false.

Here is a small sample of the code behind this function:

        if (useHyphen)
        {
            Guid hyphenGuid = Guid.NewGuid();
            string finalGuid = "";

            if (useBraces)
                finalGuid = hyphenGuid.ToString("B");
            else finalGuid = hyphenGuid.ToString();

            if (useUppercase)
                return new OkObjectResult(finalGuid.ToUpper());
            return new OkObjectResult(finalGuid);
        }

Tickets Short GUID Generator Function

This function will generate a unique identifier using a year. This function accepts 1 optional query parameter:

  • year: year to take as a reference for calculating the unique identifier.
    • The default value is 1978.

Here is a small sample of the code behind this function:

var ticks = new DateTime(year, 1, 1).Ticks;
var ans = DateTime.Now.Ticks - ticks;
var uniqueId = ans.ToString("x");

Youtube-like GUID Generator Function

This function allows you to generate a short GUID like in YouTube (N7Et6c9nL9w).

This was made just for fun, but here is a small sample of the code behind this function:

tring base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray());

Tiny Id Generator Function

This function is another way that I used in the past, in BizTalk Server projects, to generate a tiny identifier. But looking now that I’m writing this blog post, it looks like a Youtube-like GUID.

Here is a small sample of the code behind this function:

Guid guid = Guid.NewGuid();
            string modifiedBase64 = Convert.ToBase64String(guid.ToByteArray())
                .Replace('+', '-').Replace('/', '_') // avoid invalid URL characters
                .Substring(0, 22);

Where can I download it

You can download the complete Azure Functions source code here:

Once again, thank my team member Luis Rigueira for testing and helping me develop some of these function with me!

Hope you find this helpful! So, if you liked the content or found it helpful and want to help me write more content, you can buy (or help buy) my son a Star Wars Lego! 

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.

He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira

May 8, 2023 Weekly Update on Microsoft Integration Platform & Azure iPaaS

May 8, 2023 Weekly Update on Microsoft Integration Platform & Azure iPaaS

__CONFIG_colors_palette__{“active_palette”:0,”config”:{“colors”:{“f3080”:{“name”:”Main Accent”,”parent”:-1},”f2bba”:{“name”:”Main Light 10″,”parent”:”f3080″},”trewq”:{“name”:”Main Light 30″,”parent”:”f3080″},”poiuy”:{“name”:”Main Light 80″,”parent”:”f3080″},”f83d7″:{“name”:”Main Light 80″,”parent”:”f3080″},”frty6″:{“name”:”Main Light 45″,”parent”:”f3080″},”flktr”:{“name”:”Main Light 80″,”parent”:”f3080″}},”gradients”:[]},”palettes”:[{“name”:”Default”,”value”:{“colors”:{“f3080”:{“val”:”rgb(23, 23, 22)”,”hsl”:{“h”:60,”s”:0.02,”l”:0.09}},”f2bba”:{“val”:”rgba(23, 23, 22, 0.5)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.5}},”trewq”:{“val”:”rgba(23, 23, 22, 0.7)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.7}},”poiuy”:{“val”:”rgba(23, 23, 22, 0.35)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.35}},”f83d7″:{“val”:”rgba(23, 23, 22, 0.4)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.4}},”frty6″:{“val”:”rgba(23, 23, 22, 0.2)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.2}},”flktr”:{“val”:”rgba(23, 23, 22, 0.8)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.8}}},”gradients”:[]},”original”:{“colors”:{“f3080”:{“val”:”rgb(23, 23, 22)”,”hsl”:{“h”:60,”s”:0.02,”l”:0.09}},”f2bba”:{“val”:”rgba(23, 23, 22, 0.5)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.5}},”trewq”:{“val”:”rgba(23, 23, 22, 0.7)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.7}},”poiuy”:{“val”:”rgba(23, 23, 22, 0.35)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.35}},”f83d7″:{“val”:”rgba(23, 23, 22, 0.4)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.4}},”frty6″:{“val”:”rgba(23, 23, 22, 0.2)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.2}},”flktr”:{“val”:”rgba(23, 23, 22, 0.8)”,”hsl_parent_dependency”:{“h”:60,”s”:0.02,”l”:0.09,”a”:0.8}}},”gradients”:[]}}]}__CONFIG_colors_palette__

Azure Logic Apps team is interested in your feedback – Logic Apps Developer Experience and Tools

Azure Logic Apps team is interested in your feedback – Logic Apps Developer Experience and Tools

We all must love this Logic App team for engagement with the community over the last few months! Always trying to listen to the client and community feedback in order for them to prioritize investments in Logic Apps based on our real needs.

And once again, the Logic App team wants to listen to our feedback! And this time, on the topic we all developers or consultants were also anxiously waiting for Developer Experience and Tools. At least I was!

Logic Apps Developer Experience and Tools Survey

With this new survey, the Logic App team seeks feedback on how you guys want to have or imagine having XML Support inside Logic Apps. They want to learn about your needs and feedback on the current Logic Apps workflows support for XML and to provide us information about potential scenarios that you want to see covered around XML and SOAP:

  • Which Logic Apps model(s) are you using today?
  • Which tools have you used to develop Logic Apps?
  • When developing Logic Apps Standard, which environment do you mainly use? 
  • In what scenarios do you use Azure portal more for developing Logic Apps Standard?
  • Rank the new capabilities of Azure Portal experience for Logic Apps Standard.
  • If you can choose one IDE for developing Logic Apps Standard locally, which IDE do you want to use? Visual Studio Code or Visual Studio.
  • Why do you want to use Visual Studio instead of VS Code for developing Logic Apps Standard locally?
  • Rank the new capabilities of IDE experience for Logic Apps Standard.

THIS IS YOUR OPPORTUNITY! Don’t complain that the developing experience is not that good or you prefer using Visual Studio rather than Visual Studio Code for developing Logic Apps in the future if you don’t fill out this form. The survey does not take long to respond to, and this is your opportunity to try to change and influence the next set of features.

I did my part!

Please fill out the following survey to help Azure Logic Apps: 

On a final note, congratulations to the Logic App team for being so engaged with the community!

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.

He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira

Base64 Decode Windows Tool

Base64 Decode Windows Tool

In our Integration projects, especially nowadays on Azure Integration Services, sometimes we have the need to work with Base64 strings format. This is very common in some connectors inside Logic App, where the request or response is in Base64, like the Service Bus or the HTTP. And when we need to debug or troubleshoot our solution or business process, we need to understand what is the request and response payload. That means that we need most of the time to decode the Base64 string.

And I know what you guys are thinking… I also was thinking that way! Why do you need a Windows tool if we have plenty of online tools like https://www.base64decode.org/ that can easily do the job simply and fashionably?

And my straightforward and honest answer is privacy/security! The problem with using these online tools is that we never know behind the scenes what they are doing. Are you sure that they are not keeping logs of the inputs we provide and the result outputs? That is the magic question because we often have sensitive (private) information on those Base64 strings, like a connection string or usernames and passwords. And we need to be careful about where we put this information.

I have an amazing Ethical hacking friend, Nino Crudele, and every time I speak with him about security, I’m always more suspicious about how to use specific tools available on the web or, in general, how to secure my personal stuff and my solutions. And even speaking with Michael Stephenson, something that we try to do regularly, we share these concerns, and it was Michael that raised my suspicions about the decode online tools. Since that talk, I have stopped using them and decided to create my personal tool.

Base64 Decode Windows tool

This is a very simple Windows tool that allows you to decode your data. This is a handy tool if you have to deal with Base64 format.

To not raise the same suspicions about this tool, the source code is available on GitHub!

Download

Hope you find this useful! So, if you liked the content or found it useful and want to help me write more content, you can buy (or help buy) my son a Star Wars Lego! 

Credits

  • Luis Rigueira | Member of my team and one of the people responsible for developing this tool.
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.

He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira

Azure Logic Apps team is interested in your feedback – XML Support in Logic Apps Survey

Azure Logic Apps team is interested in your feedback – XML Support in Logic Apps Survey

And once again, the Logic App team wants to listen to our feedback! And this time, on the topic we all developers or consultants were anxiously waiting for, specially BizYalk Server developers: XML Support in Logic Apps!

XML Support in Logic Apps Survey

With this new survey, the Logic App team seeks feedback on how you guys want to have or imagine having XML Support inside Logic Apps. They want to learn about your needs and feedback on the current Logic Apps workflows support for XML and to provide us information about potential scenarios that you want to see covered around XML and SOAP:

  • What industry do you work in?
  • Information about the current XML capabilities of Logic Apps Workflows
    • Have you used Transform XML, XPath,  XML Validation, Transform XML to JSON, or Transform XML to TEXT actions? Do they fulfill your needs?
    • What is your biggest challenge in dealing with XML Documents in Azure Logic Apps workflows?
    • How are you currently dealing with XMLs documents with schemas definitions (XSDs) in Azure Logic Apps workflows? 
    • Are you currently converting SOAP to REST services or calling SOAP services from Logic Apps? If so, what procedure do you follow?
    • Are you familiar with the HTTP connector? Does it address your needs? 
    • Are you familiar with the Custom Connector experience that supports SOAP? Does it address your needs?
    • How are you retrieving individual data elements from an XML document and then using that value in an action?
    • Are you migrating schemas from BizTalk or other products to Azure Logic Apps?
    • (For Consumption Only) How would you rate the XML capabilities of the Enterprise Integration Pack?
    • Please Rank the areas you feel Azure Logic Apps should include XML native support.

THIS IS YOUR OPPORTUNITY! Don’t complain that the developing experience is not that good or you missing XML capabilities inside Logic App in the future if you don’t fill out this form. The survey does not take long to respond to, and this is your opportunity to try to change and influence the next set of features.

I did my part!

Please fill out the following survey to help Azure Logic Apps: 

On a final note, congratulations to the Logic App team for being so engaged with the community over the last few months! Keep this engagement active, and please continue to do a great job!

Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc.

He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.
View all posts by Sandro Pereira