{"componentChunkName":"component---src-templates-blog-list-js","path":"/blog/2/","result":{"data":{"allMarkdownRemark":{"edges":[{"node":{"id":"b82efea5-d373-5210-b7c7-525b2cb02612","html":"<p><a href=\"https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals#application-registration\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Application registration, service principal</a>, <a href=\"https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">system-assigned managed identity, user-assigned managed identity</a>, Enterprise Application, these are just a few concepts in Microsoft Identity Platform which helps businesses protect their applications and provide authentication and authorization using Azure Active Directory (aka AAD).</p>\n<p>There are many scenarios which can be covered using these concepts and although Microsoft has a ton of documentation around these, people get confused simply because of sheer amount of information to digest. So the point of these series is to get people to understand these concepts and apply them in their products developed on top of Azure AD without having to get information overload. In this post we will cover the basics.</p>\n<!--more-->\n<h2 id=\"pre-requisites\" style=\"position:relative;\"><a href=\"#pre-requisites\" aria-label=\"pre requisites permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Pre-requisites</h2>\n<p>Before we start going through these concepts, it’s worth mentioning we’re assuming our readers already know about a few concepts such as:</p>\n<ul>\n<li><a href=\"https://docs.microsoft.com/en-us/azure/active-directory/authentication/overview-authentication\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Authentication</a></li>\n<li><a href=\"https://docs.microsoft.com/en-us/azure/active-directory/develop/authentication-vs-authorization\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Authorization</a></li>\n<li><a href=\"https://docs.microsoft.com/en-us/azure/active-directory/authentication/concept-mfa-howitworks\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Multi-Factor authentication</a></li>\n<li><a href=\"https://docs.microsoft.com/en-us/azure/active-directory/manage-apps/what-is-single-sign-on\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Single sign-on</a></li>\n</ul>\n<p>Before we go into Azure AD topics, we need to be on the same page with a few standards which are widely used in our industry.</p>\n<h2 id=\"openid-connect\" style=\"position:relative;\"><a href=\"#openid-connect\" aria-label=\"openid connect permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OpenID Connect</h2>\n<p><a href=\"https://openid.net/connect/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OpenID Connect (aka OIDC)</a> is an authentication protocol which makes things simple when it comes to authenticating a user or device. It leverages a trusted identity provider for authentication, and deals with applications in which users will sign into. For more information please refer to <a href=\"https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/auth-oidc\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">our documentation here</a>.</p>\n<h2 id=\"oauth-20\" style=\"position:relative;\"><a href=\"#oauth-20\" aria-label=\"oauth 20 permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>OAuth 2.0</h2>\n<p>While OIDC deals with authentication, it relies on <a href=\"https://oauth.net/2/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">OAuth 2.0</a> for authorization which allows a user to grant limited access to an application to its protected resources. This protocol is designed to work with HTTP protocol and separates the role of client from the resource owner. Again for more information please refer to <a href=\"https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/auth-oauth2\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">our documentation</a>.</p>\n<p>Now that we know enough about these concepts, let’s dip our toes into the ocean.</p>\n<h2 id=\"service-principal\" style=\"position:relative;\"><a href=\"#service-principal\" aria-label=\"service principal permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Service Principal</h2>\n<p>Microsoft identity platform allows accessing resources to entities by a security principal which in case of a user is called <em>User Principal</em> and in terms of an application is called <em>Security Principal</em>. This object defines the access policy and permissions for the application in your tenant. This object is responsible for enabling core features such as authentication and authorization. There are different types of service principal, application, managed identity and legacy.</p>\n<h2 id=\"application-registration\" style=\"position:relative;\"><a href=\"#application-registration\" aria-label=\"application registration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Application Registration</h2>\n<p>First off, we need to emphasize something, don’t get this confused with a web or console application. Since OAuth 2.0 and OpenID Connect work allow your applications to deal with users, Microsoft Identity Platform is restricting the identity and access management only for registered applications. This is where application registration comes into place, think of it as an entity representing your own application. This entity is registered in your tenant (Azure Active Directory instance dedicated to your organization) and you have full control over it.</p>\n<p>Through this app registration you get to specify which type of application will be using this to perform authentication, what type of scenarios are going to be covered (Client Credentials flow, Authorization Code flow, etc), whether it’s a single tenant app or a multi tenant one, etc. All of these are called identity configuration.</p>\n<p>Your app registration has two entities associated to it behind the scenes, <em>Application Object</em> and a <em>Service Principal Object</em>.</p>\n<h3 id=\"application-object\" style=\"position:relative;\"><a href=\"#application-object\" aria-label=\"application object permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Application Object</h3>\n<p>This object hold all the configuration of your application such as its name, and it’s properties such as a callback URL, logout URL, etc.</p>\n<h2 id=\"managed-identity\" style=\"position:relative;\"><a href=\"#managed-identity\" aria-label=\"managed identity permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Managed Identity</h2>\n<p>Managed identities are created to allow organizations and specifically developers to enable authentication and authorization without the need to have any credentials in place. This will simplify and secure the application implementation and mitigates many security risks which is caused by credentials leaked either by being committed to source code or being shared with many people. Just bare in mind that managed identities are designed to grant access to Azure Resources, meaning you can’t use a managed identity to secure an application hosted outside Azure.</p>\n<p>There are two types of managed identities, system assigned and user assigned. System assigned are created and destroyed with the service they belong to, whereas user assigned are independent services which have their own lifecycle and can be assigned to multiple cloud resources. You can see all of these in the below picture:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/f1a459b5982d9051293a1efcebab7814/eb645/AADIdentities.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 66.66666666666666%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAABJ0AAASdAHeZh94AAACC0lEQVR42qWTS2/TQBRG83/5B6yQUBdly4IFogghUqnLIsRTiFJoqQJUaUrTRkmTOE7sJI7jd/zM4Y7bsOlDCK5kj+3xnPvd785UuIyCJXZHY7Z/xKQ3ICty/iUq6rZcKiBoOzW69zfQ9w5J/geoIglDAt/DNca4c4e+YRBEEXEQEMq4VFn/BugKqDEe82U45MxxKNIUQ8b1owYPz8+pTqZ8ME2yOOaimtvBlZ8CWmueclcAm90esSTwPI/v8zkv9CFVXadpWXjOnCRNLqDFzdCKLQs116UvoxcGxIsFM9siiQIW8q4MXsg305hw2mij9w1cz7lRaaUoinJRmsR4doDWNmk3dHrHU/TOVFTFROGCk4MBX18d8+NjC8cKiKLweuAqk+v4tGtTWt8mdGoWxmmAKwlCpVr867VGnNS6NA7adJoaY/E9Fb+vdvlS+SKKsQy3hPieAomXvluW6/s+eZ6hqimWRfms5jVNE2tiqS69um2U0ixPybK0XLBSPrNm2HKV1khkMqe21ZuzPZ79es3nUR1bGrb6v3KdD2mc0Bp2eVrb5tHuFpv1t/SH2sWJEnAgNjypb3Pn5ToP9p8zsE1WlV4LLLKcznRAtfmetd0N7n16zPG4TZ5k5bzaVpptsHX4js6oTygWFbcpVBGWPkZ0TY3hzMSVU7RqgmpSFEiX8yW5JM+y7I+HvwGcZeEyxjtYUQAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Azure Active Directory Security Principal types\"\n        title=\"\"\n        src=\"/static/f1a459b5982d9051293a1efcebab7814/302a4/AADIdentities.png\"\n        srcset=\"/static/f1a459b5982d9051293a1efcebab7814/01bf6/AADIdentities.png 270w,\n/static/f1a459b5982d9051293a1efcebab7814/07484/AADIdentities.png 540w,\n/static/f1a459b5982d9051293a1efcebab7814/302a4/AADIdentities.png 1080w,\n/static/f1a459b5982d9051293a1efcebab7814/0d292/AADIdentities.png 1620w,\n/static/f1a459b5982d9051293a1efcebab7814/b3608/AADIdentities.png 2160w,\n/static/f1a459b5982d9051293a1efcebab7814/eb645/AADIdentities.png 2500w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"enterprise-application\" style=\"position:relative;\"><a href=\"#enterprise-application\" aria-label=\"enterprise application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Enterprise Application</h2>\n<p>And at last we have to talk about Enterprise Applications, these applications are generally representing applications that are created by other organizations and are accessible for you to subscribe to or use. Some are free to use whereas some you have to pay for. Something worth mentioning is that you would have an enterprise application even for your own apps. You can view a list of these applications from the <a href=\"https://docs.microsoft.com/en-us/azure/active-directory/saas-apps/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure App Gallery</a>. Once you have added the application to your tenant it will appear in your enterprise application menu in your Azure AD blade.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 800px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/d34bdb1d13f055f3a40484db210fe3ba/5a190/enterprise-applications-in-nav.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 60.370370370370374%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAABJ0AAASdAHeZh94AAACBUlEQVR42o1SXavUMBDtv1Yf7oe7y15WEH3a+wU+CfsbBF2vD1fh+iAiKCirqNvWbZsmbfqRNk2Ok+xFFxSvA4dJhsmZMzMJThdP8PbjGu8+hfiwivBwvsD+ZI7D6QlGszOMZ+ce7jy5d47J9BQH4zn2xse4NTrB/uwR9ih2e3SMOxQPDp5z3H2a4nDJ8PiNwLOvGsvvFstvBhdrixchPC4IlzGweN/j6LLG9GWNMfmjVw3uX7V48Frh7IojWGUtwjhBynKIQkJ1Gnowf0Jv0TsMu36AbAeIpqezRhDzGlGaI+USvKx9UKnOE3fk9TCg6zpCT4QafU/oFHbNWuthjEGQ8xyMMbRti7qSSEWLXGoiV2AFnZ0vtz6nOyt7UmNQE6dUFnUHDxIITh0GhZSerO97KPJJkiHLsl/Vja++o8Yr2p6lrHw3xlgPIQoEWdVCE5kzpRREWVKiRF1XVKjB4FtWpL6iWO1zXGvOtO5pLMq/NzQOIYRTWIClKSoiGmhWiSgRRhGiKKZFMa98s9nQPUJKeaXLoyJ/s4qKBuvVF/z4vEJMEGGIhoKSHrkNmutEWVVe2U3mCgVJkoOTAkUkmlpyCpIkoXnWYLJD3gwYqLW2/d3qPwnLpkFRFv5LuNW7BfE8386Lvog2Fv9rnpDRIHnO0RBx68lLT+bvRG6vV2rtzcRO1E+OA4gdHm2BBwAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Enterprise Applications in Azure Active Directory\"\n        title=\"\"\n        src=\"/static/d34bdb1d13f055f3a40484db210fe3ba/5a190/enterprise-applications-in-nav.png\"\n        srcset=\"/static/d34bdb1d13f055f3a40484db210fe3ba/01bf6/enterprise-applications-in-nav.png 270w,\n/static/d34bdb1d13f055f3a40484db210fe3ba/07484/enterprise-applications-in-nav.png 540w,\n/static/d34bdb1d13f055f3a40484db210fe3ba/5a190/enterprise-applications-in-nav.png 800w\"\n        sizes=\"(max-width: 800px) 100vw, 800px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>There are multiple different concepts when it comes to Azure Active Directory and using it for authentication and authorization of your applications. In this post we reviewed a few of the terms which are used in many different scenarios and saw what they are and when the come into picture. Hopefully now you have the background to delve into our next series of posts which cover scenarios and how to implement them using these entities.</p>\n<h2 id=\"up-next\" style=\"position:relative;\"><a href=\"#up-next\" aria-label=\"up next permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Up next</h2>\n<p>There are many different scenarios which can be addressed using Azure AD. Here are a few:</p>\n<ul>\n<li>A single page application (aka SPA) consuming a REST API both hosted on <a href=\"https://azure.microsoft.com/en-au/services/app-service/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure App Services</a> (using two separate app registration)</li>\n<li>A SPA consuming an <a href=\"https://azure.microsoft.com/en-au/services/functions/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Function</a> (using app registration and managed identity)</li>\n<li>A SPA consuming an API hosted on <a href=\"https://azure.microsoft.com/en-au/services/api-management/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure API Management</a></li>\n<li>A multi-tenant API with a allowed list of tenants (using app registration and managed identity)</li>\n<li>Device code flow for input constraint devices such as Smart TV</li>\n<li>Using managed identity to access protected resources with EasyAuth</li>\n</ul>\n<p>In the upcoming series we will tackle each of these in turn, so stay tuned.</p>","timeToRead":4,"frontmatter":{"title":"Azure Active Directory - Concepts simplified 🔑","unformattedDate":"2021-07-02T00:00:00.000Z","date":"Jul 02, 2021","path":"/azure-ad-concepts/","author":"Yaser Adel Mehraban","tags":["showdev","azure","AAD","OAuth"],"thumbnail":null}}},{"node":{"id":"6d57c7aa-5f97-5164-a4fa-2ccacf70cdde","html":"<p>If you have deployed a resource in <a href=\"https://azure.microsoft.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft Azure</a> as part of your CI/CD pipeline you have probably worked with <a href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ARM templates</a>. These templates can be used to automate your resource deployment to Azure and help you to have consistent environments whether it’s for testing, development or production purposes. However, there are some shortcomings when it comes to complex environments especially when you have many resources and the dependency between them makes the templates to be either super busy, very complex, or unreadable.</p>\n<p>For that Microsoft has introduced <a href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/bicep-overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Bicep</a> which is designed to overcome these issues and help you with your infrastructure as code setup.</p>\n<!--more-->\n<h2 id=\"whats-not-working-with-arm-templates\" style=\"position:relative;\"><a href=\"#whats-not-working-with-arm-templates\" aria-label=\"whats not working with arm templates permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What’s not working with ARM templates?</h2>\n<p>Although there are some great features which make working with ARM templates a good experience such as functions, variables, nested templates etc, there is some room for improvements regarding below which has been raised by the community:</p>\n<ul>\n<li><strong>No comments</strong>: As of now you can’t use comments in the JSON files used by <a href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/overview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Resource Manager</a>. Since the users of ARM templates are mainly developers, comments would potentially help the next user to better understand the template and what’s going on in it. I’d personally argue with the fact that if you need comments in a template it probably means you need to refactor it, however, this is something which could come handy at times.</li>\n<li><strong>Parameter duplication</strong>: Since ARM templates are reusable, you would normally use parameters for customising the resource naming, number of resources to be deployed, pricing tier and so on. The problem is that these parameters would be needed and if you haven’t provided a default value you would get an error. So you might end up with lots of parameters repeated in different files for different environments, or simply replicating a single file and have lot’s of extra parameters which are not needed.</li>\n<li><strong>Validation</strong>: Although there is a validate command you can use to validate your templates, there might be times where validation doesn’t show you enough information or is not enough to prevent a failure in the actual run.</li>\n</ul>\n<h2 id=\"what-is-bicep\" style=\"position:relative;\"><a href=\"#what-is-bicep\" aria-label=\"what is bicep permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>What is Bicep?</h2>\n<p>Bicep is a DSL (domain specific language) which can be used to write your Infrastructure as Code (IaC). Instead of writing ARM templates you write your code with Bicep and it will transpile it to ARM for you. It simplifies the authoring experience and addresses some of the issues we mentioned earlier. Compared to using JSON, Bicep can help you simplify the template definition a great deal.</p>\n<p>Let’s see this using a simple example. Imagine you are trying to create a storage account in Azure, with ARM template this is the minimum you will need:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"89049079508803910000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{\r\n  &quot;\\$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,\r\n  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,\r\n  &quot;parameters&quot;: {\r\n    &quot;storageAccountType&quot;: {\r\n      &quot;type&quot;: &quot;secureString&quot;\r\n    }\r\n  },\r\n  &quot;variables&quot;: {\r\n    &quot;diagStorageAccountName&quot;: &quot;[concat('diags', uniqueString(resourceGroup().id))]&quot;\r\n  },\r\n  &quot;resources&quot;: [\r\n    {\r\n      &quot;type&quot;: &quot;Microsoft.Storage/storageAccounts&quot;,\r\n      &quot;apiVersion&quot;: &quot;2019-06-01&quot;,\r\n      &quot;name&quot;: &quot;[variables('diagStorageAccountName')]&quot;,\r\n      &quot;location&quot;: &quot;[resourceGroup().location]&quot;,\r\n      &quot;sku&quot;: {\r\n        &quot;name&quot;: &quot;[parameters('storageAccountType')]&quot;\r\n      },\r\n      &quot;kind&quot;: &quot;Storage&quot;\r\n    }\r\n  ]\r\n}`, `89049079508803910000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"$schema\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"contentVersion\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1.0.0.0\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"parameters\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"storageAccountType\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"secureString\"</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"variables\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"diagStorageAccountName\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"[concat('diags', uniqueString(resourceGroup().id))]\"</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"resources\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\r\n    <span class=\"token punctuation\">{</span>\r\n      <span class=\"token property\">\"type\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Microsoft.Storage/storageAccounts\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"apiVersion\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"2019-06-01\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"[variables('diagStorageAccountName')]\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"location\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"[resourceGroup().location]\"</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"sku\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"[parameters('storageAccountType')]\"</span>\r\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token property\">\"kind\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Storage\"</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">]</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Using Bicep it will be simplified to:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"98328451992535710000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@secure()\r\nparam storageAccountType string\r\nparam location string = resourceGroup().location\r\nvar diagStorageAccountName = concat('diags', uniqueString(resourceGroup().id))\r\nresource diagsAccount 'Microsoft.Storage/storageAccounts@2019-06-01' = {\r\n  name: diagStorageAccountName\r\n  location: location\r\n  sku: {\r\n    name: storageAccountType\r\n  }\r\n  kind: 'Storage'\r\n}`, `98328451992535710000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">@<span class=\"token function\">secure</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\r\nparam storageAccountType string\r\nparam location string <span class=\"token operator\">=</span> <span class=\"token function\">resourceGroup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>location\r\n<span class=\"token keyword\">var</span> diagStorageAccountName <span class=\"token operator\">=</span> <span class=\"token function\">concat</span><span class=\"token punctuation\">(</span><span class=\"token string\">'diags'</span><span class=\"token punctuation\">,</span> <span class=\"token function\">uniqueString</span><span class=\"token punctuation\">(</span><span class=\"token function\">resourceGroup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>id<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\r\nresource diagsAccount <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> diagStorageAccountName\r\n  <span class=\"token literal-property property\">location</span><span class=\"token operator\">:</span> location\r\n  <span class=\"token literal-property property\">sku</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageAccountType\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token literal-property property\">kind</span><span class=\"token operator\">:</span> <span class=\"token string\">'Storage'</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You can see how much time and space you could be saving if you were to use Bicep.</p>\n<h2 id=\"benefits\" style=\"position:relative;\"><a href=\"#benefits\" aria-label=\"benefits permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Benefits</h2>\n<p>When it comes to the benefits of using Bicep, there is a list published in our documentation:</p>\n<ul>\n<li>Support for all resource types and API versions.</li>\n<li>Better authoring experience using editors such as VS Code (you will get validation, type-safety, intellisense).</li>\n<li>Modularity can be achieved using <a href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/bicep-modules\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">modules</a>. You can have modules representing an entire environment or a set of shared resources and use them anywhere in a Bicep file.</li>\n<li>Integration with Azure services such as Azure Policy, Templates specs, and Blueprints.</li>\n<li>No need to store a state file or keep any state. You can even use the <a href=\"https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-deploy-what-if\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">what-if operation</a> to preview your changes before deploying them.</li>\n<li>Bicep is open source with a strong community supporting it.</li>\n</ul>\n<h2 id=\"syntax\" style=\"position:relative;\"><a href=\"#syntax\" aria-label=\"syntax permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Syntax</h2>\n<p>Every Bicep resource will have the below syntax:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"6742287103600564000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`resource <symbolic-name> '<resource-type>@<api-version>\\` = {  \r\n  //properties\r\n  name: 'bicepstorage2063'\r\n  location: 'northcentralus'  \r\n  properties: {\r\n    //...sub properties\r\n  }\r\n}`, `6742287103600564000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">resource <span class=\"token operator\">&lt;</span>symbolic<span class=\"token operator\">-</span>name<span class=\"token operator\">></span> '<span class=\"token operator\">&lt;</span>resource<span class=\"token operator\">-</span>type<span class=\"token operator\">></span>@<span class=\"token operator\">&lt;</span>api<span class=\"token operator\">-</span>version<span class=\"token operator\">></span>` <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>  \r\n  <span class=\"token comment\">//properties</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'bicepstorage2063'</span>\r\n  <span class=\"token literal-property property\">location</span><span class=\"token operator\">:</span> <span class=\"token string\">'northcentralus'</span>  \r\n  <span class=\"token literal-property property\">properties</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token comment\">//...sub properties</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Where:</p>\n<ul>\n<li><code class=\"language-text\">resource</code>: is a reserved keyword.</li>\n<li><code class=\"language-text\">symbolic name</code>: is an identifier within the Bicep file which can be used to reference this resource elsewhere.</li>\n<li><code class=\"language-text\">resource-type</code>: is the type of the resource you’re defining, e.g. <code class=\"language-text\">Microsoft.Storage</code>.</li>\n<li><code class=\"language-text\">api-version</code>: each resource provider publishes its own API version which defines which version of the Azure Resource Manager REST API should be used to deploy this resource.</li>\n<li><code class=\"language-text\">properties</code>: these are the resource specific properties. For example every resource has a <code class=\"language-text\">name</code> and <code class=\"language-text\">location</code>. In addition some have sub properties which you can pass on.</li>\n</ul>\n<h2 id=\"parameters\" style=\"position:relative;\"><a href=\"#parameters\" aria-label=\"parameters permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Parameters</h2>\n<p>When we talk about infrastructure as a code and reusability of our templates, we definitely end up using parameters to customise our resources. Be its name, sku, username or password, we will need to change these per environment or application.</p>\n<p>In a Bicep file you can define the parameters that need to be passed to it when deploying resources. You can put validation on the parameter value, provide default value, and limit it to allowed values. The format of a parameter will be such as below:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"41498154437868110000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`param <parameter-name> <parameter-type> = <parameter-value>`, `41498154437868110000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">param <span class=\"token operator\">&lt;</span>parameter<span class=\"token operator\">-</span>name<span class=\"token operator\">></span> <span class=\"token operator\">&lt;</span>parameter<span class=\"token operator\">-</span>type<span class=\"token operator\">></span> <span class=\"token operator\">=</span> <span class=\"token operator\">&lt;</span>parameter<span class=\"token operator\">-</span>value<span class=\"token operator\">></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Where:</p>\n<ul>\n<li><code class=\"language-text\">param</code>: is a reserved keyword.</li>\n<li><code class=\"language-text\">parameter-name</code> is the name of the parameter.</li>\n<li><code class=\"language-text\">parameter-type</code>: is the type of the parameter such as <code class=\"language-text\">string</code>, <code class=\"language-text\">object</code>, etc.</li>\n<li><code class=\"language-text\">parameter-value</code>: is the value of the parameter you’re passing in.</li>\n</ul>\n<p>Let’s review two examples to get a better understanding of the structure.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"36259808003817517000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@minLength(3)\r\n@maxLength(24)\r\nparam storageName string`, `36259808003817517000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">@<span class=\"token function\">minLength</span><span class=\"token punctuation\">(</span><span class=\"token number\">3</span><span class=\"token punctuation\">)</span>\r\n@<span class=\"token function\">maxLength</span><span class=\"token punctuation\">(</span><span class=\"token number\">24</span><span class=\"token punctuation\">)</span>\r\nparam storageName string</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>In this example you’re limiting the <code class=\"language-text\">storageName</code> parameter’s value length to be between 3 and 24 characters. Or:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"38591841801205720000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@allowed([\r\n  'Standard_LRS'\r\n  'Standard_GRS'\r\n  'Standard_RAGRS'\r\n  'Standard_ZRS'\r\n  'Premium_LRS'\r\n  'Premium_ZRS'\r\n  'Standard_GZRS'\r\n  'Standard_RAGZRS'\r\n])\r\nparam storageRedundancy string = 'Standard_LRS'`, `38591841801205720000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">@<span class=\"token function\">allowed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span>\r\n  <span class=\"token string\">'Standard_LRS'</span>\r\n  <span class=\"token string\">'Standard_GRS'</span>\r\n  <span class=\"token string\">'Standard_RAGRS'</span>\r\n  <span class=\"token string\">'Standard_ZRS'</span>\r\n  <span class=\"token string\">'Premium_LRS'</span>\r\n  <span class=\"token string\">'Premium_ZRS'</span>\r\n  <span class=\"token string\">'Standard_GZRS'</span>\r\n  <span class=\"token string\">'Standard_RAGZRS'</span>\r\n<span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span>\r\nparam storageRedundancy string <span class=\"token operator\">=</span> <span class=\"token string\">'Standard_LRS'</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>In this example you’re specifying the allowed values for the <code class=\"language-text\">storageRedundancy</code> parameter and also provide the default value if nothing is provided during the deployment.</p>\n<p>With ARM templates you had to use a separate file to pass the parameters during the deployments usually with a name ending in <code class=\"language-text\">.parameters.json</code>. In Bicep you need to use the same JSON file to pass the parameters in:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"29877751431927680000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{\r\n  &quot;\\$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#&quot;,\r\n  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,\r\n  &quot;parameters&quot;: {\r\n    &quot;storageName&quot;: {\r\n      &quot;value&quot;: &quot;myuniquestoragename&quot;\r\n    },\r\n    &quot;storageRedundancy&quot;: {\r\n      &quot;value&quot;: &quot;Standard_GZRS&quot;\r\n    }\r\n  }\r\n}`, `29877751431927680000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"$schema\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"contentVersion\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1.0.0.0\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"parameters\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"storageName\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token property\">\"value\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"myuniquestoragename\"</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token property\">\"storageRedundancy\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token property\">\"value\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Standard_GZRS\"</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"variables\" style=\"position:relative;\"><a href=\"#variables\" aria-label=\"variables permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Variables</h2>\n<p>Similar to parameters, variables play an important part in our templates, especially when it comes to naming conventions. These can store complex expressions to keep our templates clean and their maintenance simple. In Bicep variables are defined using the <code class=\"language-text\">var</code> keyword:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4255964063126272000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var <variable-name> = <value>`, `4255964063126272000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> <span class=\"token operator\">&lt;</span>variable<span class=\"token operator\">-</span>name<span class=\"token operator\">></span> <span class=\"token operator\">=</span> <span class=\"token operator\">&lt;</span>value<span class=\"token operator\">></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Where <code class=\"language-text\">variable-name</code> is the name of your variable. For example in our previous Bicep file we could have used a variable for our storage name:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87376983147780730000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`var storageAccName = 'sa\\${uniqueString(resourceGroup().id)}'\r\n\r\nresource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {\r\n  name: storageAccountName\r\n  //...\r\n}`, `87376983147780730000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">var</span> storageAccName <span class=\"token operator\">=</span> <span class=\"token string\">'sa${uniqueString(resourceGroup().id)}'</span>\r\n\r\nresource stg <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageAccountName\r\n  <span class=\"token comment\">//...</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Since we need a unique name for our storage account the <code class=\"language-text\">uniqueString</code> function is used (Don’t worry about that for now). The point is that we can create variables and use them in our template with ease.</p>\n<p>There are multiple variable types you can use:</p>\n<ul>\n<li>String</li>\n<li>Boolean</li>\n<li>Numeric</li>\n<li>Object</li>\n<li>Array</li>\n</ul>\n<h2 id=\"expressions\" style=\"position:relative;\"><a href=\"#expressions\" aria-label=\"expressions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Expressions</h2>\n<p>Expressions are used in our templates for variety of reasons, from getting the current location of the resource group to subscription id or the current datetime.</p>\n<h3 id=\"functions\" style=\"position:relative;\"><a href=\"#functions\" aria-label=\"functions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>functions</h3>\n<p>The good thing is that <strong>ANY</strong> valid <a href=\"https://docs.microsoft.com/azure/azure-resource-manager/templates/template-functions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ARM template function</a> is also a valid Bicep function.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"98394324568209650000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`param currentTime string = utcNow()\r\n\r\nvar location = resourceGroup().location\r\n\r\nvar makeCapital = toUpper('all lowercase')`, `98394324568209650000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">param currentTime string <span class=\"token operator\">=</span> <span class=\"token function\">utcNow</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span>\r\n\r\n<span class=\"token keyword\">var</span> location <span class=\"token operator\">=</span> <span class=\"token function\">resourceGroup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>location\r\n\r\n<span class=\"token keyword\">var</span> makeCapital <span class=\"token operator\">=</span> <span class=\"token function\">toUpper</span><span class=\"token punctuation\">(</span><span class=\"token string\">'all lowercase'</span><span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"ternary-operator\" style=\"position:relative;\"><a href=\"#ternary-operator\" aria-label=\"ternary operator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Ternary operator</h3>\n<p>To use conditions in your deployments you would use the <code class=\"language-text\">if</code> function in ARM templates, however, that’s not supported in Bicep. Instead, you can leverage the <strong>ternary operator</strong>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"61109158035236540000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`param globalRedundancy bool = true\r\n\r\nresource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {\r\n  name: storageAccountName\r\n  location: location\r\n  kind: 'Storage'\r\n  sku: {\r\n    name: globalRedundancy ? 'Standard_GRS' : 'Standard_LRS' // if true --> GRS, else --> LRS\r\n  }\r\n}`, `61109158035236540000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">param globalRedundancy bool <span class=\"token operator\">=</span> <span class=\"token boolean\">true</span>\r\n\r\nresource stg <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageAccountName\r\n  <span class=\"token literal-property property\">location</span><span class=\"token operator\">:</span> location\r\n  <span class=\"token literal-property property\">kind</span><span class=\"token operator\">:</span> <span class=\"token string\">'Storage'</span>\r\n  <span class=\"token literal-property property\">sku</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> globalRedundancy <span class=\"token operator\">?</span> <span class=\"token string\">'Standard_GRS'</span> <span class=\"token operator\">:</span> <span class=\"token string\">'Standard_LRS'</span> <span class=\"token comment\">// if true --> GRS, else --> LRS</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"output\" style=\"position:relative;\"><a href=\"#output\" aria-label=\"output permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Output</h2>\n<p>ARM templates have an output section where you could send information out of your pipeline to be accessed within other deployments or subsequent tasks. In Bicep you have the same concept via the <code class=\"language-text\">output</code> keyword.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"31804564174769220000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {\r\n  //...\r\n}\r\n\r\noutput storageId string = stg.id`, `31804564174769220000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">resource stg <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token comment\">//...</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\noutput storageId string <span class=\"token operator\">=</span> stg<span class=\"token punctuation\">.</span>id</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This will return the storage id out to be used later.</p>\n<h2 id=\"loops\" style=\"position:relative;\"><a href=\"#loops\" aria-label=\"loops permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Loops</h2>\n<p>In ARM templates if you wanted to deploy a resource multiple times you could leverage the <code class=\"language-text\">copy</code> operator to add a resource <code class=\"language-text\">n</code> times based on the loop count. In Bicep you have the <code class=\"language-text\">for</code> operator at your disposal:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"81950892359645680000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`resource foo 'my.provider/type@2021-03-01' = [for <ITERATOR_NAME> in <ARRAY> = {...}]`, `81950892359645680000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">resource foo <span class=\"token string\">'my.provider/type@2021-03-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token keyword\">for</span> <span class=\"token operator\">&lt;</span><span class=\"token constant\">ITERATOR_NAME</span><span class=\"token operator\">></span> <span class=\"token keyword\">in</span> <span class=\"token operator\">&lt;</span><span class=\"token constant\">ARRAY</span><span class=\"token operator\">></span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span><span class=\"token operator\">...</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Where <code class=\"language-text\">ITERATOR_NAME</code> is a new symbol that’s only available inside your resource declaration.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"44081067315813850000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`param containerNames array = [\r\n  'images'\r\n  'videos'\r\n  'pdf'\r\n]\r\n\r\nresource blob 'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01' = [for name in containerNames: {\r\n  name: '\\${stg.name}/default/\\${name}'\r\n  //...\r\n}]`, `44081067315813850000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">param containerNames array <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span>\r\n  <span class=\"token string\">'images'</span>\r\n  <span class=\"token string\">'videos'</span>\r\n  <span class=\"token string\">'pdf'</span>\r\n<span class=\"token punctuation\">]</span>\r\n\r\nresource blob <span class=\"token string\">'Microsoft.Storage/storageAccounts/blobServices/containers@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span><span class=\"token keyword\">for</span> name <span class=\"token keyword\">in</span> <span class=\"token literal-property property\">containerNames</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'${stg.name}/default/${name}'</span>\r\n  <span class=\"token comment\">//...</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This snippet creates three containers within the storage account in a loop.</p>\n<h2 id=\"existing-keyword\" style=\"position:relative;\"><a href=\"#existing-keyword\" aria-label=\"existing keyword permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Existing keyword</h2>\n<p>If you want to deploy a resource which is depending on an existing resource you can leverage the <code class=\"language-text\">existing</code> keyword.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"86023062335860130000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`resource stg 'Microsoft.Storage/storageAccounts@2019-06-01' existing = {\r\n  name: storageAccountName\r\n}`, `86023062335860130000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">resource stg <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> existing <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageAccountName\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>You won’t need the other properties since the resource already exists. You need enough information to be able to identify the resource. Now that you have this reference, you can use it in other parts of your deployment.</p>\n<h2 id=\"modules\" style=\"position:relative;\"><a href=\"#modules\" aria-label=\"modules permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Modules</h2>\n<p>In ARM templates you had the concept of linked templates when it came to reuse a template in other deployments. In Bicep you have <code class=\"language-text\">modules</code>. You can define a resource in a module and reuse that module in other Bicep files.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"62695813755436270000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`.\r\n├── main.bicep\r\n└── stg.bicep`, `62695813755436270000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token builtin class-name\">.</span>\r\n├── main.bicep\r\n└── stg.bicep</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>In our <code class=\"language-text\">stg</code> file you will define the resource, its parameters, variables, outputs, etc:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"87023659166820140000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`//stg.bicep\r\nparam storageAccountName\r\nvar storageSku = 'Standard_LRS'\r\n\r\nresource stg 'Microsoft.Storage/storageAccounts@2019-06-01' = {\r\n  name: storageAccountName\r\n  location: resourceGroup().location\r\n  kind: 'Storage'\r\n  sku: {\r\n    name: storageSku\r\n  }\r\n}`, `87023659166820140000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">//stg.bicep</span>\r\nparam storageAccountName\r\n<span class=\"token keyword\">var</span> storageSku <span class=\"token operator\">=</span> <span class=\"token string\">'Standard_LRS'</span>\r\n\r\nresource stg <span class=\"token string\">'Microsoft.Storage/storageAccounts@2019-06-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageAccountName\r\n  <span class=\"token literal-property property\">location</span><span class=\"token operator\">:</span> <span class=\"token function\">resourceGroup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>location\r\n  <span class=\"token literal-property property\">kind</span><span class=\"token operator\">:</span> <span class=\"token string\">'Storage'</span>\r\n  <span class=\"token literal-property property\">sku</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> storageSku\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>And in the <code class=\"language-text\">main</code> file you will reuse the storage account as a module using the <code class=\"language-text\">module</code> keyword:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"18716601360509990000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`//main.bicep\r\nmodule stg './storage.bicep' = {\r\n  name: 'storageDeploy'\r\n  params: {\r\n    storageAccountName: '<YOURUNIQUESTORAGENAME>'\r\n  }\r\n}\r\n\r\noutput storageName array = stg.outputs.containerProps`, `18716601360509990000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">//main.bicep</span>\r\nmodule stg <span class=\"token string\">'./storage.bicep'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'storageDeploy'</span>\r\n  <span class=\"token literal-property property\">params</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">storageAccountName</span><span class=\"token operator\">:</span> <span class=\"token string\">'&lt;YOURUNIQUESTORAGENAME>'</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\noutput storageName array <span class=\"token operator\">=</span> stg<span class=\"token punctuation\">.</span>outputs<span class=\"token punctuation\">.</span>containerProps</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You only need to pass the required properties which in case of our storage account is the name.</p>\n<h2 id=\"the-code-classlanguage-textanycode-keyword\" style=\"position:relative;\"><a href=\"#the-code-classlanguage-textanycode-keyword\" aria-label=\"the code classlanguage textanycode keyword permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The <code class=\"language-text\">any</code> keyword</h2>\n<p>There might be some cases where Bicep throws a false positive when it comes to errors or warnings. This might happen based on different situations such as the API not having the correct type definition. You can use the <code class=\"language-text\">any</code> keyword to get around these situations when defining resources which have incorrect types assigned. One of examples is the container instances CPU and Memory properties which expect an <code class=\"language-text\">int</code>, but in fact they are <code class=\"language-text\">number</code> since you can pass non-integer values such as <code class=\"language-text\">0.5</code>.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"29004892493880185000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`resource wpAci 'microsoft.containerInstance/containerGroups@2019-12-01' = {\r\n  name: 'wordpress-containerinstance'\r\n  location: location\r\n  properties: {\r\n    containers: [\r\n      {\r\n        name: 'wordpress'\r\n        properties: {\r\n          ...\r\n          resources: {\r\n            requests: {\r\n              cpu: any('0.5')\r\n              memoryInGB: any('0.7')\r\n            }\r\n          }\r\n        }\r\n      }\r\n    ]\r\n  }\r\n}`, `29004892493880185000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">resource wpAci <span class=\"token string\">'microsoft.containerInstance/containerGroups@2019-12-01'</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'wordpress-containerinstance'</span>\r\n  <span class=\"token literal-property property\">location</span><span class=\"token operator\">:</span> location\r\n  <span class=\"token literal-property property\">properties</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">containers</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span>\r\n      <span class=\"token punctuation\">{</span>\r\n        <span class=\"token literal-property property\">name</span><span class=\"token operator\">:</span> <span class=\"token string\">'wordpress'</span>\r\n        <span class=\"token literal-property property\">properties</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n          <span class=\"token operator\">...</span>\r\n          <span class=\"token literal-property property\">resources</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n            <span class=\"token literal-property property\">requests</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n              <span class=\"token literal-property property\">cpu</span><span class=\"token operator\">:</span> <span class=\"token function\">any</span><span class=\"token punctuation\">(</span><span class=\"token string\">'0.5'</span><span class=\"token punctuation\">)</span>\r\n              <span class=\"token literal-property property\">memoryInGB</span><span class=\"token operator\">:</span> <span class=\"token function\">any</span><span class=\"token punctuation\">(</span><span class=\"token string\">'0.7'</span><span class=\"token punctuation\">)</span>\r\n            <span class=\"token punctuation\">}</span>\r\n          <span class=\"token punctuation\">}</span>\r\n        <span class=\"token punctuation\">}</span>\r\n      <span class=\"token punctuation\">}</span>\r\n    <span class=\"token punctuation\">]</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>By using <code class=\"language-text\">any</code> and passing the value you can get around the possible errors which might be raised during the build or the validation stage.</p>\n<h2 id=\"tooling\" style=\"position:relative;\"><a href=\"#tooling\" aria-label=\"tooling permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Tooling</h2>\n<p>In terms of tooling the support is the same if not better than the ARM templates.</p>\n<h3 id=\"vs-code-extension\" style=\"position:relative;\"><a href=\"#vs-code-extension\" aria-label=\"vs code extension permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>VS Code extension</h3>\n<p>VS Code comes with <a href=\"https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">an official extension for Bicep</a>. This extension gives you validation, intellisense, dot property access, snippets etc.</p>\n<h3 id=\"cicd\" style=\"position:relative;\"><a href=\"#cicd\" aria-label=\"cicd permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>CI/CD</h3>\n<p>If you’re using <a href=\"https://github.com/features/actions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub Actions</a> for your CI/CD pipeline, there is already a <a href=\"https://github.com/marketplace/actions/bicep-build\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Bicep action</a> created by our developer advocate <a href=\"https://github.com/justinyoo\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Justin Yoo</a> which you can use to build you bicep file and deploy it to Azure.</p>\n<h3 id=\"cli\" style=\"position:relative;\"><a href=\"#cli\" aria-label=\"cli permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>CLI</h3>\n<p>Bicep comes with a CLI that you can install locally on <a href=\"https://github.com/Azure/bicep/blob/main/docs/installing.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Windows, MacOS, and Linux</a>. That gives you the ability to build and deploy your Bicep files with <a href=\"https://docs.microsoft.com/en-us/cli/azure\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure CLI</a>.</p>\n<h2 id=\"summery\" style=\"position:relative;\"><a href=\"#summery\" aria-label=\"summery permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summery</h2>\n<p>In short, I highly recommend using Bicep and improving your IaC and deployments. Of course if your ARM templates are too many, or very complex you might benefit from converting them more, but if you already have a streamlined pipeline with maintainable templates, you could keep them and create any new template using Bicep instead.</p>","timeToRead":8,"frontmatter":{"title":"From ARM to Bicep 💪🏽","unformattedDate":"2021-05-10T00:00:00.000Z","date":"May 10, 2021","path":"/from-arm-to-bicep/","author":"Yaser Adel Mehraban","tags":["showdev","azure","arm","bicep"],"thumbnail":null}}},{"node":{"id":"1374100d-ff53-504a-a87b-0d1cb761ce52","html":"<p><a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Functions</a> is one of the the serverless services in Azure which allows you to run your business logic without worrying about where it’s running and how it scales. But it being serverless is not the highlight of this amazing service, the way it’s designed which allows you to leverage a very diverse set of triggers and input/output bindings without writing much code is to me the best of the best. So in this article I’ve decided to take you on a journey with a few of the common triggers and bindings and show you how to set them up quickly and without writing any unnecessary code.</p>\n<!--more-->\n<h2 id=\"working-with-azure-functions-locally\" style=\"position:relative;\"><a href=\"#working-with-azure-functions-locally\" aria-label=\"working with azure functions locally permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Working with Azure Functions locally</h2>\n<p>Before we delve into the main topic of our discussion, I should quickly show you how easy it is to create and run these functions locally using a code editor or even a simple terminal.</p>\n<p>If you’re using <a href=\"https://code.visualstudio.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Visual Studio Code</a>, you need to install the <a href=\"https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Functions Extensions</a>. For the command line approach, you’ll need the <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#v2\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Functions Core Tools</a> and either <a href=\"https://docs.microsoft.com/en-us/cli/azure/install-azure-cli\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure CLI</a> or <a href=\"https://docs.microsoft.com/en-us/powershell/azure/install-az-ps\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure PowerShell</a> to create Azure resources. You can also use the <a href=\"https://azure.microsoft.com/downloads/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Visual Studio 2019</a> in which case you need to install its Azure Development component. It has built in templates for you to get started and be able to create functions and deploy them to Azure right there and then. You can find <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">the tutorial here</a>.</p>\n<p>The good news is that all of these tools are cross platform and compatible with Windows, Linux and MacOS.</p>\n<p>I’ll just show you one of them and leave the rest to you. After you have installed the necessary tools, open a terminal (I use <a href=\"https://docs.microsoft.com/en-us/windows/terminal/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Windows Terminal</a>) and initialize a new function using the init command:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"44259619370752840000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`func init myLocalFunctionProj --dotnet\r\n\r\ncd myLocalFunctionProj`, `44259619370752840000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">func init myLocalFunctionProj <span class=\"token parameter variable\">--dotnet</span>\r\n\r\n<span class=\"token builtin class-name\">cd</span> myLocalFunctionProj</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>You can use other languages too. For a list of supported languages please <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/supported-languages\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">visit the our documentation</a>.</p>\n<p>Now that you have a project you can create one or multiple functions in it:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"28113084530803010000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`func new --name HttpExample --template &quot;HTTP trigger&quot; --authlevel &quot;function&quot;`, `28113084530803010000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">func new <span class=\"token parameter variable\">--name</span> HttpExample <span class=\"token parameter variable\">--template</span> <span class=\"token string\">\"HTTP trigger\"</span> <span class=\"token parameter variable\">--authlevel</span> <span class=\"token string\">\"function\"</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>This will create an HTTP triggered function for you which you can run using:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"76882159076317920000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`func start`, `76882159076317920000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">func start</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>Now you can send request to your function, so open a browser and visit <code class=\"language-text\">http://localhost:7071/api/HttpExample?name=Yas</code>, the function should return the result and the browser should show you a <code class=\"language-text\">Hello Yas</code> message. You’re now ready to explore triggers and binding.</p>\n<h2 id=\"triggers\" style=\"position:relative;\"><a href=\"#triggers\" aria-label=\"triggers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Triggers</h2>\n<p>There are quite a few triggers available which will cover almost any scenario you could think of. From a simple HTTP trigger to timer and blob, and a whole lot more are supported without you needing to write code. If I wanted to just quickly go through the most common ones, they are:</p>\n<table>\n<thead>\n<tr>\n<th>Type</th>\n<th>Purpose</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><strong>Timer</strong></td>\n<td>Execute a function at a set interval.</td>\n</tr>\n<tr>\n<td><strong>HTTP</strong></td>\n<td>Execute a function when an HTTP request is received.</td>\n</tr>\n<tr>\n<td><strong>Blob</strong></td>\n<td>Execute a function when a file is uploaded or updated in Azure Blob storage.</td>\n</tr>\n<tr>\n<td><strong>Queue</strong></td>\n<td>Execute a function when a message is added to an Azure Storage queue.</td>\n</tr>\n<tr>\n<td><strong>Azure Cosmos DB</strong></td>\n<td>Execute a function when a document changes in a collection.</td>\n</tr>\n<tr>\n<td><strong>Event Hub</strong></td>\n<td>Execute a function when an event hub receives a new event.</td>\n</tr>\n<tr>\n<td><strong>Event Grid</strong></td>\n<td>Execute a function when an event is sent to Event Grid topics or queues.</td>\n</tr>\n</tbody>\n</table>\n<p>All of my examples will be using Csharp but you can use your language of choice. Examples of those can be found on <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings?tabs=csharp\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Functions documentation site</a>.</p>\n<h3 id=\"timer-trigger\" style=\"position:relative;\"><a href=\"#timer-trigger\" aria-label=\"timer trigger permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Timer trigger</h3>\n<p>Timer triggers allow you to run the function on a schedule. All you need is a <code class=\"language-text\">TimerTrigger</code> attribute with its configuration:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"52844536508427080000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[FunctionName(&quot;TimerTriggerCSharp&quot;)]\r\npublic static void Run([TimerTrigger(&quot;0 */5 * * * *&quot;)]TimerInfo myTimer, ILogger log)\r\n{\r\n    if (myTimer.IsPastDue)\r\n    {\r\n        log.LogInformation(&quot;Timer is running late!&quot;);\r\n    }\r\n    log.LogInformation(\\$&quot;Csharp Timer trigger function executed at: {DateTime.Now}&quot;);\r\n}`, `52844536508427080000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"TimerTriggerCSharp\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>\r\n<span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token return-type class-name\"><span class=\"token keyword\">void</span></span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">TimerTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"0 */5 * * * *\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span><span class=\"token class-name\">TimerInfo</span> myTimer<span class=\"token punctuation\">,</span> <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>myTimer<span class=\"token punctuation\">.</span>IsPastDue<span class=\"token punctuation\">)</span>\r\n    <span class=\"token punctuation\">{</span>\r\n        log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Timer is running late!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n    log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"Csharp Timer trigger function executed at: </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">DateTime<span class=\"token punctuation\">.</span>Now</span><span class=\"token punctuation\">}</span></span><span class=\"token string\">\"</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This function will run based on the <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer?tabs=csharp#ncrontab-expressions\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CRON expression</a> you have specified. Our example CRON expression will run the function 12 times an hour, every 5th minute of every hour of the day.</p>\n<h3 id=\"blob-trigger\" style=\"position:relative;\"><a href=\"#blob-trigger\" aria-label=\"blob trigger permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Blob trigger</h3>\n<p>Blob triggers are very powerful and allow you to cover verity of scenarios from creating an image thumbnail on upload to check a file for virus.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"77324647010042500000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[FunctionName(&quot;BlobTriggerCSharp&quot;)]        \r\npublic static void Run([BlobTrigger(&quot;container-name/{name}&quot;)] Stream myBlob, string name, ILogger log)\r\n{\r\n    log.LogInformation(\\$&quot;Csharp Blob trigger function Processed blob\\n Name:{name} \\n Size: {myBlob.Length} Bytes&quot;);\r\n}`, `77324647010042500000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"BlobTriggerCSharp\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>        \r\n<span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token return-type class-name\"><span class=\"token keyword\">void</span></span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">BlobTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"container-name/{name}\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\">Stream</span> myBlob<span class=\"token punctuation\">,</span> <span class=\"token class-name\"><span class=\"token keyword\">string</span></span> name<span class=\"token punctuation\">,</span> <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">{</span>\r\n    log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"Csharp Blob trigger function Processed blob\\n Name:</span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">name</span><span class=\"token punctuation\">}</span></span><span class=\"token string\"> \\n Size: </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">myBlob<span class=\"token punctuation\">.</span>Length</span><span class=\"token punctuation\">}</span></span><span class=\"token string\"> Bytes\"</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<blockquote>\n<p>💡 You will need the <code class=\"language-text\">Microsoft.Azure.WebJobs.Extensions</code> package to use these attributes.</p>\n</blockquote>\n<h3 id=\"cosmos-db-trigger\" style=\"position:relative;\"><a href=\"#cosmos-db-trigger\" aria-label=\"cosmos db trigger permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Cosmos DB trigger</h3>\n<p>If you wanted to become aware when a document is inserted/updated in your Cosmos DB, you can use this trigger:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"4272786169052955600\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[FunctionName(&quot;CosmosTrigger&quot;)]\r\npublic static void Run([CosmosDBTrigger(\r\n    databaseName: &quot;ToDoItems&quot;,\r\n    collectionName: &quot;Items&quot;,\r\n    ConnectionStringSetting = &quot;CosmosDBConnection&quot;)]IReadOnlyList<Document> documents,\r\n    ILogger log)\r\n{\r\n    if (documents != null && documents.Count > 0)\r\n    {\r\n        log.LogInformation(\\$&quot;Documents modified: {documents.Count}&quot;);\r\n        log.LogInformation(\\$&quot;First document Id: {documents[0].Id}&quot;);\r\n    }\r\n}`, `4272786169052955600`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"CosmosTrigger\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>\r\n<span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token return-type class-name\"><span class=\"token keyword\">void</span></span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">CosmosDBTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span>\r\n    <span class=\"token named-parameter punctuation\">databaseName</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"ToDoItems\"</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token named-parameter punctuation\">collectionName</span><span class=\"token punctuation\">:</span> <span class=\"token string\">\"Items\"</span><span class=\"token punctuation\">,</span>\r\n    ConnectionStringSetting <span class=\"token operator\">=</span> <span class=\"token string\">\"CosmosDBConnection\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span><span class=\"token class-name\">IReadOnlyList<span class=\"token punctuation\">&lt;</span>Document<span class=\"token punctuation\">></span></span> documents<span class=\"token punctuation\">,</span>\r\n    <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>documents <span class=\"token operator\">!=</span> <span class=\"token keyword\">null</span> <span class=\"token operator\">&amp;&amp;</span> documents<span class=\"token punctuation\">.</span>Count <span class=\"token operator\">></span> <span class=\"token number\">0</span><span class=\"token punctuation\">)</span>\r\n    <span class=\"token punctuation\">{</span>\r\n        log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"Documents modified: </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">documents<span class=\"token punctuation\">.</span>Count</span><span class=\"token punctuation\">}</span></span><span class=\"token string\">\"</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"First document Id: </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">documents<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>Id</span><span class=\"token punctuation\">}</span></span><span class=\"token string\">\"</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>All you need is the connection string in your <code class=\"language-text\">local.settings.json</code> in the connection string section:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"74298291709973070000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`{\r\n  &quot;IsEncrypted&quot;: false,\r\n  &quot;Values&quot;: {\r\n    &quot;AzureWebJobsStorage&quot;: &quot;<storage-connection-string>&quot;\r\n  },\r\n  &quot;ConnectionStrings&quot;: {\r\n    &quot;CosmosDBConnection&quot;: &quot;<cosmosdb-connection-string>&quot;\r\n  }\r\n}`, `74298291709973070000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"IsEncrypted\"</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"Values\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"AzureWebJobsStorage\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"&lt;storage-connection-string>\"</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"ConnectionStrings\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"CosmosDBConnection\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"&lt;cosmosdb-connection-string>\"</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>For all the other examples you can update your settings file accordingly. I won’t be going through more triggers because I want to show the bindings. But you can find examples of all the supported triggers in our <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=csharp\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">reference documentation section</a>.</p>\n<h2 id=\"bindings\" style=\"position:relative;\"><a href=\"#bindings\" aria-label=\"bindings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Bindings</h2>\n<p>Bindings allow you to have input and output to/from your function out of the box. This is where magic happens and it’s super powerful. For example, if you wanted to have a function which is triggered by a queue and gets a blob as input, you will need this:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"30313610721736794000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[FunctionName(&quot;BlobInput&quot;)]\r\npublic static void Run(\r\n    [QueueTrigger(&quot;queue-name&quot;)] string myQueueItem,\r\n    [Blob(&quot;container/{queueTrigger}&quot;, FileAccess.Read)] Stream myBlob,\r\n    ILogger log)\r\n{\r\n    log.LogInformation(\\$&quot;BlobInput processed blob\\n Name:{myQueueItem} \\n Size: {myBlob.Length} bytes&quot;);\r\n}`, `30313610721736794000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"BlobInput\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>\r\n<span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token return-type class-name\"><span class=\"token keyword\">void</span></span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span>\r\n    <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">QueueTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"queue-name\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\"><span class=\"token keyword\">string</span></span> myQueueItem<span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">Blob</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"container/{queueTrigger}\"</span><span class=\"token punctuation\">,</span> FileAccess<span class=\"token punctuation\">.</span>Read<span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\">Stream</span> myBlob<span class=\"token punctuation\">,</span>\r\n    <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">{</span>\r\n    log<span class=\"token punctuation\">.</span><span class=\"token function\">LogInformation</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"BlobInput processed blob\\n Name:</span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">myQueueItem</span><span class=\"token punctuation\">}</span></span><span class=\"token string\"> \\n Size: </span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">myBlob<span class=\"token punctuation\">.</span>Length</span><span class=\"token punctuation\">}</span></span><span class=\"token string\"> bytes\"</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>In this example the queue message contains the name of the blob. Or imagine people are uploading images into a blob container and you wanted an Azure Function to create thumbnails for you. You will need a blob trigger and a blob output:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"65848736243181620000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[FunctionName(&quot;CreateThumbnail&quot;)]\r\npublic static void Run(\r\n    [BlobTrigger(&quot;images/{name}&quot;)] Stream image,\r\n    [Blob(&quot;thumbnails/{name}&quot;, FileAccess.Write)] Stream thumbnail,\r\n    ILogger log)\r\n{\r\n  IImageFormat format;\r\n\r\n  using (Image<Rgba32> input = Image.Load<Rgba32>(image, out format))\r\n  {\r\n    input.Mutate(x => x.Resize(320, 200));\r\n    input.Save(output, format);\r\n  }  \r\n}`, `65848736243181620000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"CreateThumbnail\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>\r\n<span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token return-type class-name\"><span class=\"token keyword\">void</span></span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span>\r\n    <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">BlobTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"images/{name}\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\">Stream</span> image<span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">Blob</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"thumbnails/{name}\"</span><span class=\"token punctuation\">,</span> FileAccess<span class=\"token punctuation\">.</span>Write<span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\">Stream</span> thumbnail<span class=\"token punctuation\">,</span>\r\n    <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n<span class=\"token punctuation\">{</span>\r\n  <span class=\"token class-name\">IImageFormat</span> format<span class=\"token punctuation\">;</span>\r\n\r\n  <span class=\"token keyword\">using</span> <span class=\"token punctuation\">(</span><span class=\"token class-name\">Image<span class=\"token punctuation\">&lt;</span>Rgba32<span class=\"token punctuation\">></span></span> input <span class=\"token operator\">=</span> Image<span class=\"token punctuation\">.</span><span class=\"token generic-method\"><span class=\"token function\">Load</span><span class=\"token generic class-name\"><span class=\"token punctuation\">&lt;</span>Rgba32<span class=\"token punctuation\">></span></span></span><span class=\"token punctuation\">(</span>image<span class=\"token punctuation\">,</span> <span class=\"token keyword\">out</span> format<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    input<span class=\"token punctuation\">.</span><span class=\"token function\">Mutate</span><span class=\"token punctuation\">(</span>x <span class=\"token operator\">=></span> x<span class=\"token punctuation\">.</span><span class=\"token function\">Resize</span><span class=\"token punctuation\">(</span><span class=\"token number\">320</span><span class=\"token punctuation\">,</span> <span class=\"token number\">200</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    input<span class=\"token punctuation\">.</span><span class=\"token function\">Save</span><span class=\"token punctuation\">(</span>output<span class=\"token punctuation\">,</span> format<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>  \r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The two image will share the same name, although the container name is different. For the name of the output blob, you could also use some pre-defined functions such as <code class=\"language-text\">{rand-guid}</code> to generate a unique identifier or <code class=\"language-text\">{DateTime}</code> to use current time as the name, although this might not match your requirement all the times.</p>\n<p>But what if you wanted to write it into the same container? In that case you couldn’t simply use the <code class=\"language-text\">{name}</code> for your output binding. To generate the name of the output blob at runtime, you need to use imperative bindings.</p>\n<h3 id=\"ibinder\" style=\"position:relative;\"><a href=\"#ibinder\" aria-label=\"ibinder permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>IBinder</h3>\n<p>Instead of using the <code class=\"language-text\">[Blob]</code> attribute, you could use an instance of <code class=\"language-text\">IBinder</code> interface which gives you much more control over your output binding and it’s name. The same example with a binder will look like:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"59586876514796260000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`using System;\r\nusing System.IO;\r\nusing Microsoft.Azure.WebJobs;\r\nusing Microsoft.Extensions.Logging;\r\nusing SixLabors.ImageSharp;\r\nusing SixLabors.ImageSharp.Processing;\r\nusing SixLabors.ImageSharp.Formats;\r\nusing System.Threading.Tasks;\r\nusing SixLabors.ImageSharp.PixelFormats;\r\n\r\nnamespace functions\r\n{\r\n  public static class createThumbnail\r\n  {\r\n    [FunctionName(&quot;createThumbnail&quot;)]\r\n    public static async Task Run(\r\n        [BlobTrigger(&quot;images/original-{blobName}&quot;, Connection = &quot;AzureWebJobsStorage&quot;)] Stream image,\r\n        string blobName,\r\n        IBinder binder,\r\n        ILogger log)\r\n    {\r\n      IImageFormat format;\r\n\r\n      using (Image<Rgba32> input = Image.Load<Rgba32>(image, out format))\r\n      {\r\n        input.Mutate(x => x.Resize(320, 200));\r\n\r\n        using (var writer = await binder.BindAsync<Stream>(\r\n                      new BlobAttribute(\\$&quot;images/thumbnail-{blobName}&quot;, FileAccess.Write)))\r\n        {          \r\n          input.Save(writer, format);\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n`, `59586876514796260000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"csharp\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-csharp line-numbers\"><code class=\"language-csharp\"><span class=\"token keyword\">using</span> <span class=\"token namespace\">System</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">System<span class=\"token punctuation\">.</span>IO</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">Microsoft<span class=\"token punctuation\">.</span>Azure<span class=\"token punctuation\">.</span>WebJobs</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">Microsoft<span class=\"token punctuation\">.</span>Extensions<span class=\"token punctuation\">.</span>Logging</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">SixLabors<span class=\"token punctuation\">.</span>ImageSharp</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">SixLabors<span class=\"token punctuation\">.</span>ImageSharp<span class=\"token punctuation\">.</span>Processing</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">SixLabors<span class=\"token punctuation\">.</span>ImageSharp<span class=\"token punctuation\">.</span>Formats</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">System<span class=\"token punctuation\">.</span>Threading<span class=\"token punctuation\">.</span>Tasks</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">using</span> <span class=\"token namespace\">SixLabors<span class=\"token punctuation\">.</span>ImageSharp<span class=\"token punctuation\">.</span>PixelFormats</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">namespace</span> <span class=\"token namespace\">functions</span>\r\n<span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token keyword\">class</span> <span class=\"token class-name\">createThumbnail</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">FunctionName</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"createThumbnail\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span>\r\n    <span class=\"token keyword\">public</span> <span class=\"token keyword\">static</span> <span class=\"token keyword\">async</span> <span class=\"token return-type class-name\">Task</span> <span class=\"token function\">Run</span><span class=\"token punctuation\">(</span>\r\n        <span class=\"token punctuation\">[</span><span class=\"token attribute\"><span class=\"token class-name\">BlobTrigger</span><span class=\"token attribute-arguments\"><span class=\"token punctuation\">(</span><span class=\"token string\">\"images/original-{blobName}\"</span><span class=\"token punctuation\">,</span> Connection <span class=\"token operator\">=</span> <span class=\"token string\">\"AzureWebJobsStorage\"</span><span class=\"token punctuation\">)</span></span></span><span class=\"token punctuation\">]</span> <span class=\"token class-name\">Stream</span> image<span class=\"token punctuation\">,</span>\r\n        <span class=\"token class-name\"><span class=\"token keyword\">string</span></span> blobName<span class=\"token punctuation\">,</span>\r\n        <span class=\"token class-name\">IBinder</span> binder<span class=\"token punctuation\">,</span>\r\n        <span class=\"token class-name\">ILogger</span> log<span class=\"token punctuation\">)</span>\r\n    <span class=\"token punctuation\">{</span>\r\n      <span class=\"token class-name\">IImageFormat</span> format<span class=\"token punctuation\">;</span>\r\n\r\n      <span class=\"token keyword\">using</span> <span class=\"token punctuation\">(</span><span class=\"token class-name\">Image<span class=\"token punctuation\">&lt;</span>Rgba32<span class=\"token punctuation\">></span></span> input <span class=\"token operator\">=</span> Image<span class=\"token punctuation\">.</span><span class=\"token generic-method\"><span class=\"token function\">Load</span><span class=\"token generic class-name\"><span class=\"token punctuation\">&lt;</span>Rgba32<span class=\"token punctuation\">></span></span></span><span class=\"token punctuation\">(</span>image<span class=\"token punctuation\">,</span> <span class=\"token keyword\">out</span> format<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\r\n      <span class=\"token punctuation\">{</span>\r\n        input<span class=\"token punctuation\">.</span><span class=\"token function\">Mutate</span><span class=\"token punctuation\">(</span>x <span class=\"token operator\">=></span> x<span class=\"token punctuation\">.</span><span class=\"token function\">Resize</span><span class=\"token punctuation\">(</span><span class=\"token number\">320</span><span class=\"token punctuation\">,</span> <span class=\"token number\">200</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n        <span class=\"token keyword\">using</span> <span class=\"token punctuation\">(</span><span class=\"token class-name\"><span class=\"token keyword\">var</span></span> writer <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> binder<span class=\"token punctuation\">.</span><span class=\"token generic-method\"><span class=\"token function\">BindAsync</span><span class=\"token generic class-name\"><span class=\"token punctuation\">&lt;</span>Stream<span class=\"token punctuation\">></span></span></span><span class=\"token punctuation\">(</span>\r\n                      <span class=\"token keyword\">new</span> <span class=\"token constructor-invocation class-name\">BlobAttribute</span><span class=\"token punctuation\">(</span><span class=\"token interpolation-string\"><span class=\"token string\">$\"images/thumbnail-</span><span class=\"token interpolation\"><span class=\"token punctuation\">{</span><span class=\"token expression language-csharp\">blobName</span><span class=\"token punctuation\">}</span></span><span class=\"token string\">\"</span></span><span class=\"token punctuation\">,</span> FileAccess<span class=\"token punctuation\">.</span>Write<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span>\r\n        <span class=\"token punctuation\">{</span>          \r\n          input<span class=\"token punctuation\">.</span><span class=\"token function\">Save</span><span class=\"token punctuation\">(</span>writer<span class=\"token punctuation\">,</span> format<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token punctuation\">}</span>\r\n      <span class=\"token punctuation\">}</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span>\r\n</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<blockquote>\n<p>💡 The reason we added a suffix to the blob name is to prevent the infinite look when we write to the same container.</p>\n</blockquote>\n<h2 id=\"other-bindings\" style=\"position:relative;\"><a href=\"#other-bindings\" aria-label=\"other bindings permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Other bindings</h2>\n<p>There are heaps of bindings available for you to leverage and create great solutions to solve your business problems and <a href=\"https://docs.microsoft.com/en-us/azure/azure-functions/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">you can find out about them here</a>. All you need to do is to select the <code class=\"language-text\">Reference > Triggers and bindings</code> from the left hand side.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>Hope this article has been interesting enough to intrigue you to go checkout Azure Functions and leverage their power to solve your business problems. Until next post, Sayōnara 👋🏽.</p>","timeToRead":6,"frontmatter":{"title":"Exploring Azure Function Triggers and Bindings ⚡","unformattedDate":"2021-03-29T00:00:00.000Z","date":"Mar 29, 2021","path":"/azure-function-bindings/","author":"Yaser Adel Mehraban","tags":["showdev","azure","functions","serverless"],"thumbnail":null}}},{"node":{"id":"35737a5a-d577-5e27-b46a-593a7ce97558","html":"<p><a href=\"https://playwright.dev/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Playwright</a> is one of the recently released end to end testing frameworks which enables fast, reliable and capable automation and is cross platform. I really like it, but since it’s very easy to setup and the community around it is super cool, I like it even more.</p>\n<p>In this article I want to show you how you can write some tests for any <a href=\"https://vuejs.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Vue.js</a> application which is using <a href=\"https://auth0.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Auth0</a> as an identity provider. However, this could be used with any other provider too, since it covers the basics and makes you ready to write tests which cover different scenarios and user interactions.</p>\n<!--more-->\n<h2 id=\"concepts\" style=\"position:relative;\"><a href=\"#concepts\" aria-label=\"concepts permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Concepts</h2>\n<p>Before we delve into the nitty gritty of things here, we should all agree on a few concepts:</p>\n<ul>\n<li><strong>End-to-end tests:</strong> End-to-end tests (AKA E2E) are like back box testing where you don’t test individual components or unit of code, instead you focus on testing a scenario end to end. With this type of tests, you use a real instance of the application. They are ideal for creating reliable and bug free application since they mimic user behaviour.</li>\n<li><strong>Vue.js:</strong> is a fantastic progressive frontend framework which is ideal for building user interfaces. It’s like a middle ground between Angular and React and is built from ground up with developers in mind. It’s easy to pickup and integrate with other libraries or existing projects.</li>\n<li><strong>Auth0:</strong> is an identity provider which has gained a really good reputation thanks to its complete solution which helps people secure their applications and add features like single sign on, multi-factor authentication and social media login to their applications.</li>\n</ul>\n<h2 id=\"stage-is-set\" style=\"position:relative;\"><a href=\"#stage-is-set\" aria-label=\"stage is set permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Stage is set</h2>\n<p>I have an application which is written in <em>Vue.js</em>. I have added authentication and authorization using <em>Auth0</em> and have different features shown/hidden to users based on their access levels.</p>\n<p>However, my unit and component tests don’t seem to cover some scenarios which our end users will do when interacting with our application. Some of this is because I have to use mocks when doing component testing, and unit tests don’t cover more than a piece of code.</p>\n<p>Now I need a way to test my application as if a user is sitting in front of their computer and uses our application. To achieve this, I will have to use end-to-end tests.</p>\n<h2 id=\"options\" style=\"position:relative;\"><a href=\"#options\" aria-label=\"options permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Options</h2>\n<p>There are some great E2E test frameworks out there, and here are just a few:</p>\n<ul>\n<li>Protractor</li>\n<li>Nightwatch.js</li>\n<li>Cypress</li>\n<li>TestCafe</li>\n<li>Playwright</li>\n<li>WebdriverJS</li>\n<li>OpenTest</li>\n<li>Puppeteer</li>\n</ul>\n<p>And many more. However, I really like Playwright because it is easy to use and setup, it’s cross platform and integrates nicely with every CI/CD pipeline you’d think of.</p>\n<h2 id=\"the-code\" style=\"position:relative;\"><a href=\"#the-code\" aria-label=\"the code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The code</h2>\n<p>So I have an application which basically lists movies and people can buy tickets and go watch it in an imaginary gold cinema. The app also has an admin page where only users with administrator role can access. So let’s break through the code bit by bit:</p>\n<h3 id=\"main-setup\" style=\"position:relative;\"><a href=\"#main-setup\" aria-label=\"main setup permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Main setup</h3>\n<p>In order for us to use the <em>Auth0</em> as a plugin with <em>Vue 3</em> we need to create a plugin and set it up in our main file. However, Vue 3 has changed the way we setup the plugins. So here is our little plugin (note code has been removed for brevity):</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"50710122437299950000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`import createAuth0Client from '@auth0/auth0-spa-js';\r\nlet client;\r\n///all the other methods and definitions\r\nexport const setupAuth = async (options, callbackRedirect) => {\r\n  client = await createAuth0Client({\r\n    ...options,\r\n  });\r\n  try {\r\n    if (window.location.search.includes('code=') \r\n      && window.location.search.includes('state=')) {\r\n      const { appState } = await client.handleRedirectCallback();\r\n      callbackRedirect(appState);\r\n    }\r\n  }\r\n  //...\r\n  return {\r\n    install: app => {\r\n      app.config.globalProperties.\\$auth = authPlugin;\r\n    },\r\n  };\r\n}`, `50710122437299950000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">import</span> createAuth0Client <span class=\"token keyword\">from</span> <span class=\"token string\">'@auth0/auth0-spa-js'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">let</span> client<span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">///all the other methods and definitions</span>\r\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">const</span> <span class=\"token function-variable function\">setupAuth</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">options<span class=\"token punctuation\">,</span> callbackRedirect</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  client <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token function\">createAuth0Client</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\r\n    <span class=\"token operator\">...</span>options<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>window<span class=\"token punctuation\">.</span>location<span class=\"token punctuation\">.</span>search<span class=\"token punctuation\">.</span><span class=\"token function\">includes</span><span class=\"token punctuation\">(</span><span class=\"token string\">'code='</span><span class=\"token punctuation\">)</span> \r\n      <span class=\"token operator\">&amp;&amp;</span> window<span class=\"token punctuation\">.</span>location<span class=\"token punctuation\">.</span>search<span class=\"token punctuation\">.</span><span class=\"token function\">includes</span><span class=\"token punctuation\">(</span><span class=\"token string\">'state='</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> appState <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> client<span class=\"token punctuation\">.</span><span class=\"token function\">handleRedirectCallback</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token function\">callbackRedirect</span><span class=\"token punctuation\">(</span>appState<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token comment\">//...</span>\r\n  <span class=\"token keyword\">return</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token function-variable function\">install</span><span class=\"token operator\">:</span> <span class=\"token parameter\">app</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n      app<span class=\"token punctuation\">.</span>config<span class=\"token punctuation\">.</span>globalProperties<span class=\"token punctuation\">.</span>$auth <span class=\"token operator\">=</span> authPlugin<span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>We also implement a route guard in the same file:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"23697899876380934000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`import { computed, watchEffect } from 'vue';\r\n\r\nconst authPlugin = {\r\n  isAuthenticated: computed(() => state.isAuthenticated),\r\n  loading: computed(() => state.loading),\r\n  user: computed(() => state.user),\r\n  popupOpen: computed(() => state.popupOpen),\r\n  claims: computed(() => state.claims),\r\n  getIdTokenClaims,\r\n  getTokenSilently,\r\n  getTokenWithPopup,\r\n  handleRedirectCallback,\r\n  loginWithRedirect,\r\n  loginWithPopup,\r\n  logout,\r\n  getUser,\r\n};\r\n\r\nexport const routeGuard = (to, from, next) => {\r\n  const { isAuthenticated, loading, claims } = authPlugin;\r\n  const verify = () => {\r\n    if (!isAuthenticated.value) {\r\n      return next({ path: '/login', query: { returnUrl: to.path } });\r\n    }\r\n\r\n    if (to?.meta?.authorize) {\r\n      const roles = claims.value['http://schemas.microsoft.com/ws/2008/06/identity/claims/role'];\r\n      if (roles.find(r => r === to.meta.authorize.role)) {\r\n        return next();\r\n      } else {\r\n        return next('/unauthorized');\r\n      }\r\n    }\r\n  };\r\n  if (!loading.value) {\r\n    return verify();\r\n  }\r\n  watchEffect(() => {\r\n    if (loading.value === false && claims.value) {\r\n      return verify();\r\n    }\r\n  });\r\n};`, `23697899876380934000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> computed<span class=\"token punctuation\">,</span> watchEffect <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'vue'</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">const</span> authPlugin <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">isAuthenticated</span><span class=\"token operator\">:</span> <span class=\"token function\">computed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> state<span class=\"token punctuation\">.</span>isAuthenticated<span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">loading</span><span class=\"token operator\">:</span> <span class=\"token function\">computed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> state<span class=\"token punctuation\">.</span>loading<span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">user</span><span class=\"token operator\">:</span> <span class=\"token function\">computed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> state<span class=\"token punctuation\">.</span>user<span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">popupOpen</span><span class=\"token operator\">:</span> <span class=\"token function\">computed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> state<span class=\"token punctuation\">.</span>popupOpen<span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">claims</span><span class=\"token operator\">:</span> <span class=\"token function\">computed</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> state<span class=\"token punctuation\">.</span>claims<span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  getIdTokenClaims<span class=\"token punctuation\">,</span>\r\n  getTokenSilently<span class=\"token punctuation\">,</span>\r\n  getTokenWithPopup<span class=\"token punctuation\">,</span>\r\n  handleRedirectCallback<span class=\"token punctuation\">,</span>\r\n  loginWithRedirect<span class=\"token punctuation\">,</span>\r\n  loginWithPopup<span class=\"token punctuation\">,</span>\r\n  logout<span class=\"token punctuation\">,</span>\r\n  getUser<span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">const</span> <span class=\"token function-variable function\">routeGuard</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">to<span class=\"token punctuation\">,</span> from<span class=\"token punctuation\">,</span> next</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> isAuthenticated<span class=\"token punctuation\">,</span> loading<span class=\"token punctuation\">,</span> claims <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> authPlugin<span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">const</span> <span class=\"token function-variable function\">verify</span> <span class=\"token operator\">=</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>isAuthenticated<span class=\"token punctuation\">.</span>value<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">return</span> <span class=\"token function\">next</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/login'</span><span class=\"token punctuation\">,</span> <span class=\"token literal-property property\">query</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">returnUrl</span><span class=\"token operator\">:</span> to<span class=\"token punctuation\">.</span>path <span class=\"token punctuation\">}</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>to<span class=\"token operator\">?.</span>meta<span class=\"token operator\">?.</span>authorize<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">const</span> roles <span class=\"token operator\">=</span> claims<span class=\"token punctuation\">.</span>value<span class=\"token punctuation\">[</span><span class=\"token string\">'http://schemas.microsoft.com/ws/2008/06/identity/claims/role'</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>roles<span class=\"token punctuation\">.</span><span class=\"token function\">find</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">r</span> <span class=\"token operator\">=></span> r <span class=\"token operator\">===</span> to<span class=\"token punctuation\">.</span>meta<span class=\"token punctuation\">.</span>authorize<span class=\"token punctuation\">.</span>role<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">return</span> <span class=\"token function\">next</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">return</span> <span class=\"token function\">next</span><span class=\"token punctuation\">(</span><span class=\"token string\">'/unauthorized'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      <span class=\"token punctuation\">}</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span><span class=\"token operator\">!</span>loading<span class=\"token punctuation\">.</span>value<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">return</span> <span class=\"token function\">verify</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token function\">watchEffect</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>loading<span class=\"token punctuation\">.</span>value <span class=\"token operator\">===</span> <span class=\"token boolean\">false</span> <span class=\"token operator\">&amp;&amp;</span> claims<span class=\"token punctuation\">.</span>value<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">return</span> <span class=\"token function\">verify</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This route guard might look intimidating at first glance, but all we’re doing is to create an object which exposes the Auth0 client methods, and then checks the route for a metadata property called authorize which holds the value of the role which should have access to the page.</p>\n<p>The rest is just checking whether they match and allow the redirect or send the user to the unauthorized page.</p>\n<p>In our main file:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"5453308697629767000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`import { createApp } from 'vue';\r\nimport router from './router';\r\nimport { setupAuth } from '@/auth/auth-plugin';\r\n\r\nconst authConfig = {\r\n  domain: process.env.VUE_APP_DOMAIN,\r\n  client_id: process.env.VUE_APP_CLIENTID,\r\n  redirect_uri: process.env.VUE_APP_REDIRECT_URL,\r\n  audience: process.env.VUE_APP_AUDIENCE,\r\n  advancedOptions: {\r\n    defaultScope: 'openid profile email crud:users',\r\n  },\r\n};\r\n\r\nfunction callbackRedirect(appState) {\r\n  router.push(appState && appState.targetUrl ? appState.targetUrl : '/');\r\n}\r\n\r\nlet app = createApp(App)\r\n  .use(router);\r\n\r\nsetupAuth(authConfig, callbackRedirect).then(auth => {\r\n  app.use(auth).mount('#app');\r\n});`, `5453308697629767000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createApp <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'vue'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">import</span> router <span class=\"token keyword\">from</span> <span class=\"token string\">'./router'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> setupAuth <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@/auth/auth-plugin'</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">const</span> authConfig <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">domain</span><span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">VUE_APP_DOMAIN</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">client_id</span><span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">VUE_APP_CLIENTID</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">redirect_uri</span><span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">VUE_APP_REDIRECT_URL</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">audience</span><span class=\"token operator\">:</span> process<span class=\"token punctuation\">.</span>env<span class=\"token punctuation\">.</span><span class=\"token constant\">VUE_APP_AUDIENCE</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">advancedOptions</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">defaultScope</span><span class=\"token operator\">:</span> <span class=\"token string\">'openid profile email crud:users'</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">function</span> <span class=\"token function\">callbackRedirect</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">appState</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n  router<span class=\"token punctuation\">.</span><span class=\"token function\">push</span><span class=\"token punctuation\">(</span>appState <span class=\"token operator\">&amp;&amp;</span> appState<span class=\"token punctuation\">.</span>targetUrl <span class=\"token operator\">?</span> appState<span class=\"token punctuation\">.</span>targetUrl <span class=\"token operator\">:</span> <span class=\"token string\">'/'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span>\r\n\r\n<span class=\"token keyword\">let</span> app <span class=\"token operator\">=</span> <span class=\"token function\">createApp</span><span class=\"token punctuation\">(</span>App<span class=\"token punctuation\">)</span>\r\n  <span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>router<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token function\">setupAuth</span><span class=\"token punctuation\">(</span>authConfig<span class=\"token punctuation\">,</span> callbackRedirect<span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">then</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">auth</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  app<span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>auth<span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">mount</span><span class=\"token punctuation\">(</span><span class=\"token string\">'#app'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Here we’re simply creating an options object which is requied by the Auth0 SDK which has the client id, domain etc.</p>\n<p>And once that’s done, we will create our app but instead of using the plugin right away, we will call the <code class=\"language-text\">setupAuth</code> which will then creates the client instance and returns the plugin instance. Now all we need to do is to call the <code class=\"language-text\">.use</code> and use our plugin instance.</p>\n<h2 id=\"login-component\" style=\"position:relative;\"><a href=\"#login-component\" aria-label=\"login component permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Login component</h2>\n<p>Now that we’ve got our auth plugin setup, it’s time to setup our login component. Fortunately it doesn’t require much code:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"71260637379965240000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<div v-if=&quot;!user&quot;>\r\n  <a href=&quot;#&quot; class=&quot;signup&quot; @click.prevent=&quot;login&quot;>\r\n    You need to sign in first!\r\n  </a>\r\n</div>`, `71260637379965240000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">v-if</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>!user<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>signup<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">@click.prevent</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>login<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n    You need to sign in first!\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>And in our component:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"70866490106700690000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`/// code removed for brevity\r\nexport default {\r\n  methods: {\r\n    login: async function() {\r\n      try {\r\n        await this.\\$auth.loginWithPopup();\r\n        const user = await this.\\$auth.getUser();\r\n        const accessToken = await this.\\$auth.getTokenSilently();\r\n        this.\\$store.commit('SET_USER', user);\r\n        //...\r\n      }\r\n    }\r\n  }\r\n  //...\r\n}`, `70866490106700690000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token comment\">/// code removed for brevity</span>\r\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">methods</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token function-variable function\">login</span><span class=\"token operator\">:</span> <span class=\"token keyword\">async</span> <span class=\"token keyword\">function</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">try</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">await</span> <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>$auth<span class=\"token punctuation\">.</span><span class=\"token function\">loginWithPopup</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token keyword\">const</span> user <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>$auth<span class=\"token punctuation\">.</span><span class=\"token function\">getUser</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token keyword\">const</span> accessToken <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>$auth<span class=\"token punctuation\">.</span><span class=\"token function\">getTokenSilently</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token keyword\">this</span><span class=\"token punctuation\">.</span>$store<span class=\"token punctuation\">.</span><span class=\"token function\">commit</span><span class=\"token punctuation\">(</span><span class=\"token string\">'SET_USER'</span><span class=\"token punctuation\">,</span> user<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token comment\">//...</span>\r\n      <span class=\"token punctuation\">}</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token comment\">//...</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The way this login works is that by clicking on the login button there would be a popup window opened from <em>Auth0</em> where the user enters their credentials and press submit.</p>\n<h2 id=\"router-config\" style=\"position:relative;\"><a href=\"#router-config\" aria-label=\"router config permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Router config</h2>\n<p>And the last thing we would have here would be the routing configuration:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"65339191456405340000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`import { createWebHistory, createRouter } from 'vue-router';\r\nimport { routeGuard } from '@/auth/auth-plugin';\r\n//other imports\r\nexport const routes = [\r\n  {\r\n    path: '/',\r\n    component: Home,\r\n  },\r\n  //...other routes\r\n  {\r\n    path: '/login',\r\n    component: Login,\r\n  },\r\n  {\r\n    path: '/admin',\r\n    component: Admin,\r\n    beforeEnter: routeGuard,\r\n    meta: {\r\n      authorize: {\r\n        role: 'Admin',\r\n      },\r\n    },\r\n  },\r\n  {\r\n    path: '/unauthorized',\r\n    component: UnAuthorized,\r\n  },\r\n];\r\n\r\nconst router = createRouter({\r\n  history: createWebHistory(),\r\n  routes,\r\n});\r\n\r\nexport default router;`, `65339191456405340000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> createWebHistory<span class=\"token punctuation\">,</span> createRouter <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'vue-router'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">import</span> <span class=\"token punctuation\">{</span> routeGuard <span class=\"token punctuation\">}</span> <span class=\"token keyword\">from</span> <span class=\"token string\">'@/auth/auth-plugin'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">//other imports</span>\r\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">const</span> routes <span class=\"token operator\">=</span> <span class=\"token punctuation\">[</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/'</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">component</span><span class=\"token operator\">:</span> Home<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token comment\">//...other routes</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/login'</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">component</span><span class=\"token operator\">:</span> Login<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/admin'</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">component</span><span class=\"token operator\">:</span> Admin<span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">beforeEnter</span><span class=\"token operator\">:</span> routeGuard<span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">meta</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token literal-property property\">authorize</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token literal-property property\">role</span><span class=\"token operator\">:</span> <span class=\"token string\">'Admin'</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">path</span><span class=\"token operator\">:</span> <span class=\"token string\">'/unauthorized'</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">component</span><span class=\"token operator\">:</span> UnAuthorized<span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">]</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">const</span> router <span class=\"token operator\">=</span> <span class=\"token function\">createRouter</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">history</span><span class=\"token operator\">:</span> <span class=\"token function\">createWebHistory</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  routes<span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token keyword\">export</span> <span class=\"token keyword\">default</span> router<span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>And that’s the basics of our application. Don’t worry I will put a link to the GitHub repo at the end so you would have all the code. I just want you to know at a really high level how the app is setup.</p>\n<h2 id=\"setting-up-the-tests\" style=\"position:relative;\"><a href=\"#setting-up-the-tests\" aria-label=\"setting up the tests permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Setting up the tests</h2>\n<p>In order to add the package to our app, we will do it via the CLI. So go ahead and execute below command in your terminal at the root of your client app:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"42558914370011230000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`vue add e2e-playwright --dev`, `42558914370011230000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">vue <span class=\"token function\">add</span> e2e-playwright <span class=\"token parameter variable\">--dev</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>It will take a while and a whole bunch of stuff happens behind the scene, but it does all the heavy lifting for you, create a folder for the E2E tests, and even creates a example test for your convenience. It adds <em>Playwright</em> so you can write tests, and <em>chai</em> to handle assertions.</p>\n<h2 id=\"writing-tests\" style=\"position:relative;\"><a href=\"#writing-tests\" aria-label=\"writing tests permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Writing tests</h2>\n<p>Writing tests is the next step, for each test you have a few basic things to do. Import the necessary objects and methods:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"45511171184909240000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const { chromium } = require('playwright');\r\nconst { expect } = require('chai');`, `45511171184909240000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> chromium <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'playwright'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> <span class=\"token punctuation\">{</span> expect <span class=\"token punctuation\">}</span> <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">'chai'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>Here I am importing Chrome, but you have the option to use Safari or Firefox if you wish.</p>\n<p>Now we need some variables:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"97349117755925630000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const baseUrl = 'http://localhost:8080/';\r\nconst adminPassword = 'Super_Secure_Pass';\r\nconst adminUserName = 'admin@example.com';\r\nconst normalUserName = 'user@example.com';\r\nconst normalUserPassword = 'Super_Secure_Pass';`, `97349117755925630000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> baseUrl <span class=\"token operator\">=</span> <span class=\"token string\">'http://localhost:8080/'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> adminPassword <span class=\"token operator\">=</span> <span class=\"token string\">'Super_Secure_Pass'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> adminUserName <span class=\"token operator\">=</span> <span class=\"token string\">'admin@example.com'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> normalUserName <span class=\"token operator\">=</span> <span class=\"token string\">'user@example.com'</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> normalUserPassword <span class=\"token operator\">=</span> <span class=\"token string\">'Super_Secure_Pass'</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>I am just defining the passwords here to make it easier to understand, you make sure you have them in your environment files and use them that way so that you don’t commit user names and passwords into your source code.</p>\n<p>Now it’s time to write our tests, basically you need a describe method which is your test suite. In there you would need two variables for your browser and page instances:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"45022857140963615000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`describe('Authenticated Vue App: ', () => {\r\n  let browser;\r\n  let page;\r\n})`, `45022857140963615000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">describe</span><span class=\"token punctuation\">(</span><span class=\"token string\">'Authenticated Vue App: '</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">let</span> browser<span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">let</span> page<span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now you would need to create an instance of your browser and page. So go ahead and add a <code class=\"language-text\">beforeEach</code> method. Inside that, lunch your browser, create a new page and navigate to your home page:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"827521477648951400\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`before(async () => {\r\n  browser = await chromium.launch();\r\n  page = await browser.newPage();\r\n  await page.goto(baseUrl);\r\n});`, `827521477648951400`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">before</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  browser <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> chromium<span class=\"token punctuation\">.</span><span class=\"token function\">launch</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  page <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> browser<span class=\"token punctuation\">.</span><span class=\"token function\">newPage</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">goto</span><span class=\"token punctuation\">(</span>baseUrl<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Make sure you close these objects at the end of the tests via an <code class=\"language-text\">after</code> method:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"76574322085793630000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`after(async () => {\r\n  await page.close();\r\n  await browser.close();\r\n});`, `76574322085793630000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">after</span><span class=\"token punctuation\">(</span><span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">close</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token keyword\">await</span> browser<span class=\"token punctuation\">.</span><span class=\"token function\">close</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>You’re now ready to write your first test. In this test we’re going to go to admin page without authentication and see what happens. Based on our router guard’s code, we know that the user should be redirected to login:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"96834733429582170000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`it('An unauthenticated user should not be able to see the admin page', async () => {\r\n  await page.goto(\\`\\${baseUrl}admin\\`);\r\n  expect(page.url()).to.equal(\\`\\${baseUrl}login?returnUrl=/admin\\`);\r\n});`, `96834733429582170000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">it</span><span class=\"token punctuation\">(</span><span class=\"token string\">'An unauthenticated user should not be able to see the admin page'</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">goto</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>baseUrl<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">admin</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token function\">expect</span><span class=\"token punctuation\">(</span>page<span class=\"token punctuation\">.</span><span class=\"token function\">url</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>to<span class=\"token punctuation\">.</span><span class=\"token function\">equal</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>baseUrl<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">login?returnUrl=/admin</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>If you now run the tests by running <code class=\"language-text\">yarn test:e2e</code>, you should see the test pass.</p>\n<h3 id=\"more-complicated-tests\" style=\"position:relative;\"><a href=\"#more-complicated-tests\" aria-label=\"more complicated tests permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>More complicated tests</h3>\n<p>Now to add a spin on our test, say we wanted to actually login and see what happens. In this case we need to click on the login button, then find the opened window and fill in the username and password, then click on submit and come back to our app. This would require a bit more coding, but still easy to find out from <em>Playwright’s</em> documentation.</p>\n<p>First you would need to find the login button, then you need to use a <code class=\"language-text\">Promise.all</code> method to be able to get a reference to your popup window:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"14370454436704639000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const [popup] = await Promise.all([\r\n  page.waitForEvent('popup'),\r\n  await page.click('a.signup')      \r\n]);`, `14370454436704639000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>popup<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> Promise<span class=\"token punctuation\">.</span><span class=\"token function\">all</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span>\r\n  page<span class=\"token punctuation\">.</span><span class=\"token function\">waitForEvent</span><span class=\"token punctuation\">(</span><span class=\"token string\">'popup'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">click</span><span class=\"token punctuation\">(</span><span class=\"token string\">'a.signup'</span><span class=\"token punctuation\">)</span>      \r\n<span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now that you have the reference, you need to fill in the info and click on the login:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"68193548812897940000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`await popup.fill('input[type=&quot;email&quot;]', adminUserName);\r\nawait popup.fill('input[type=&quot;password&quot;]', adminPassword);\r\nawait popup.click('button[type=&quot;submit&quot;]');`, `68193548812897940000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">fill</span><span class=\"token punctuation\">(</span><span class=\"token string\">'input[type=\"email\"]'</span><span class=\"token punctuation\">,</span> adminUserName<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">fill</span><span class=\"token punctuation\">(</span><span class=\"token string\">'input[type=\"password\"]'</span><span class=\"token punctuation\">,</span> adminPassword<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">click</span><span class=\"token punctuation\">(</span><span class=\"token string\">'button[type=\"submit\"]'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>And at last you need to make an assertion. Say you wanted to see whether an admin user will have access to the admin page. To do the assertion, you need to hook up to the close event of the popup window. So your test will look like:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"81634561468447490000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`it('be redirected back to admin page after login', async () => {\r\n    await page.goto(\\`\\${baseUrl}admin\\`);\r\n    \r\n    const [popup] = await Promise.all([\r\n      page.waitForEvent('popup'),\r\n      await page.click('a.signup')      \r\n    ]);\r\n\r\n    popup.on('close', async () => {\r\n      expect(page.url()).to.equal(\\`\\${baseUrl}admin\\`);\r\n    });\r\n\r\n    await popup.fill('input[type=&quot;email&quot;]', adminUserName);\r\n    await popup.fill('input[type=&quot;password&quot;]', adminPassword);\r\n    await popup.click('button[type=&quot;submit&quot;]');\r\n  });`, `81634561468447490000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token function\">it</span><span class=\"token punctuation\">(</span><span class=\"token string\">'be redirected back to admin page after login'</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">goto</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>baseUrl<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">admin</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    \r\n    <span class=\"token keyword\">const</span> <span class=\"token punctuation\">[</span>popup<span class=\"token punctuation\">]</span> <span class=\"token operator\">=</span> <span class=\"token keyword\">await</span> Promise<span class=\"token punctuation\">.</span><span class=\"token function\">all</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">[</span>\r\n      page<span class=\"token punctuation\">.</span><span class=\"token function\">waitForEvent</span><span class=\"token punctuation\">(</span><span class=\"token string\">'popup'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token keyword\">await</span> page<span class=\"token punctuation\">.</span><span class=\"token function\">click</span><span class=\"token punctuation\">(</span><span class=\"token string\">'a.signup'</span><span class=\"token punctuation\">)</span>      \r\n    <span class=\"token punctuation\">]</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n    popup<span class=\"token punctuation\">.</span><span class=\"token function\">on</span><span class=\"token punctuation\">(</span><span class=\"token string\">'close'</span><span class=\"token punctuation\">,</span> <span class=\"token keyword\">async</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token function\">expect</span><span class=\"token punctuation\">(</span>page<span class=\"token punctuation\">.</span><span class=\"token function\">url</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>to<span class=\"token punctuation\">.</span><span class=\"token function\">equal</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>baseUrl<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token string\">admin</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n    <span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">fill</span><span class=\"token punctuation\">(</span><span class=\"token string\">'input[type=\"email\"]'</span><span class=\"token punctuation\">,</span> adminUserName<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">fill</span><span class=\"token punctuation\">(</span><span class=\"token string\">'input[type=\"password\"]'</span><span class=\"token punctuation\">,</span> adminPassword<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token keyword\">await</span> popup<span class=\"token punctuation\">.</span><span class=\"token function\">click</span><span class=\"token punctuation\">(</span><span class=\"token string\">'button[type=\"submit\"]'</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The reason why you’d need a <code class=\"language-text\">waitForEvent</code> method in the <code class=\"language-text\">Promise.all</code> method is that you need to wait for the popup window to be able to get a handle on it. Now if you run the tests again, they should all pass.</p>\n<h2 id=\"full-code\" style=\"position:relative;\"><a href=\"#full-code\" aria-label=\"full code permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Full code</h2>\n<p>You can find the full source code on my <a href=\"https://github.com/yashints/vue-e2e-playwright\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repository here</a>.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>And that’s how easy it is to write tests which mimic user interactions and can make you confident to ship reliable software. Happy testing and let me know what could automation have you done with Playwright if you got to that point 👋🏽👋🏽.</p>","timeToRead":8,"frontmatter":{"title":"How to end-to-end test your Vue.js apps with Playwright 🧪","unformattedDate":"2021-02-07T00:00:00.000Z","date":"Feb 07, 2021","path":"/e2e-vue-playwright/","author":"Yaser Adel Mehraban","tags":["webdev","showdev","vue","playwright"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAC4jAAAuIwF4pT92AAACPklEQVR42mNgwASMUMzAUF/PwlMw3R+IrbnzJrvyFs/wFSid6cdXOEUFJP2f4T8jAzZgf6xNxW5qpaOJXbQpiK9nFqNonp7uYLOv1VqwfLIuT/5UTd686aoMhb3SDJlTZbkrN4rjNdB5f5uP8462/+YRKf9NHGMSTZxijjsvavnvfKxzPtSlTCDKtHa7e+LOh3O91jyov8DAIHZAg88VYjADE8K0/xBbnI52LHWYXfvfxDr6s2VO1j/Hfa0vXXc2K0IMXMUGoqwC6td5L73+P2rl6eNXnCS09kpwxYLEVzEwMCMMhNrusqtJ02lPyzvzzIzfjssb/jsd7ywHiYeuWsVczwBRM0FMvtjGp+xOcV7Ch8vTvZ6ujNNZiz0M99ezgF25o6Xe/Wjff8edLefMFtfzoUQQEJxVYU/aZF8kcqzDc/Gd6a7/l8SqzYC4CdnLkEAAa7JZWiHotKv1rtO21hiY66BhBJZfrytpPJHBg31RgavTpDCdBfO95CXABjKgGwgEFqGFnCoqHuzOh9rUrDZ08qL4wN6exSI0lBNqOyMDNHZBBtUDg6weGmwMCAXAGHSOVTP2iQ8wdotyNPZO8LL0izWEedfEO0bHzDsh1Mo90tLUNd7AxjfK2sEn3NnaJ9LG2DvOzNQ91h2oVwM1HO3jOUw9Y9XMQtO1THwSTI094pRhBtp4Rwka+kVIGXvE2pi4JViZecfoW/tGaJt4ANV5xTmaeyeomnlEy+DOIUgRgQUwIacQe3tIhML0AABeULn/qZSjmwAAAABJRU5ErkJggg=="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/bf38b419a4fa82a6b763cc1b2dc46e8a/a7eab/vue-playwright.png","srcSet":"/static/bf38b419a4fa82a6b763cc1b2dc46e8a/6ed98/vue-playwright.png 750w,\n/static/bf38b419a4fa82a6b763cc1b2dc46e8a/4ce1a/vue-playwright.png 1080w,\n/static/bf38b419a4fa82a6b763cc1b2dc46e8a/a7eab/vue-playwright.png 1280w","sizes":"(min-width: 1280px) 1280px, 100vw"},"sources":[{"srcSet":"/static/bf38b419a4fa82a6b763cc1b2dc46e8a/cbeef/vue-playwright.webp 750w,\n/static/bf38b419a4fa82a6b763cc1b2dc46e8a/3cb55/vue-playwright.webp 1080w,\n/static/bf38b419a4fa82a6b763cc1b2dc46e8a/07811/vue-playwright.webp 1280w","type":"image/webp","sizes":"(min-width: 1280px) 1280px, 100vw"}]},"width":1280,"height":720}}}}}},{"node":{"id":"d37ae6d6-4052-59c9-85a3-c0540c354135","html":"<p><a href=\"https://azure.microsoft.com/en-au/services/cosmos-db/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Cosmos DB</a> is one of the foundational services in Azure, which provides high availability, global scale and an impressive performance. However, it could be a bit costly for developers to spin up an instance during their development especially if they don’t know some of the basics such as what should be the partition key, what throughput they should select and so on that much.</p>\n<p><a href=\"https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">The Azure Cosmos DB Emulator</a> is a service provided by Microsoft which allows you to emulate the Cosmos DB Service locally for development purposes. In addition, no matter whether you’re using Azure CosmosDB or not, at some point you might have to test some sort of DocumentDB locally.</p>\n<!--more-->\n<h2 id=\"intro\" style=\"position:relative;\"><a href=\"#intro\" aria-label=\"intro permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Intro</h2>\n<p>Let’s be honest, there are other ways to work with Cosmos DB without paying any money such as a <a href=\"https://azure.microsoft.com/en-us/free/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Free Trial Account</a> which gives you <strong>$200 dollars</strong> to spend over a year, or even the <a href=\"https://www.documentdb.com/sql/demo\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Cosmos DB Query Playground</a> which is an interactive website which helps you to learn the query syntax and provides you with a set of pre-defined JSON documents to work with.</p>\n<p>But eventually you either run out of money, or your product is live and your developers want to develop new features and fix bugs to be released very quickly. That’s when <em>Cosmos DB Emulator</em> really comes to the rescue. You have other advantages such as ability to work offline and or even have an Azure subscription.</p>\n<h2 id=\"features\" style=\"position:relative;\"><a href=\"#features\" aria-label=\"features permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Features</h2>\n<h3 id=\"api-set\" style=\"position:relative;\"><a href=\"#api-set\" aria-label=\"api set permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>API set</h3>\n<p>Azure Cosmos DB supports SQL API, as well as Table, MongoDB, Cassandra, and Gremlin which to me covers many scenarios from migrating an existing database from on-premise to Azure, modernising your legacy application, or create a brand new one. Azure Cosmos DB Emulator also supports these APIs although the underlying implementation details are different to the real service on Azure. In fact the emulator hides all abstractions from you and lets you focus on adding value to your team or organisation.</p>\n<blockquote>\n<p>💡 However keep in mind that the data explorer provided with the service <strong>only</strong> supports <strong>SQL API</strong> at the moment.</p>\n</blockquote>\n<h3 id=\"number-of-containers\" style=\"position:relative;\"><a href=\"#number-of-containers\" aria-label=\"number of containers permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Number of containers</h3>\n<p>The emulator allows you to create a single account with multiple (up to 25 fixed sized, or 5 unlimited) containers.</p>\n<h3 id=\"operating-system\" style=\"position:relative;\"><a href=\"#operating-system\" aria-label=\"operating system permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Operating System</h3>\n<p>At the moment, the emulator only supports 64-bit versions of Windows (Server 2012 R2, Server 2016, Server 2019, Windows 10) which demands a minimum of 2GB of RAM and 10GB of free disk space. You must also have administrative privileges to be able to install the client.</p>\n<p>In addition to that, it also comes with docker image which you can use to run the emulator in a docker container but only on windows containers. If you want to use docker in Linux or macOS, you will need to use it on a Windows virtual machine.</p>\n<h2 id=\"installation\" style=\"position:relative;\"><a href=\"#installation\" aria-label=\"installation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Installation</h2>\n<p>Simply <a href=\"https://aka.ms/cosmosdb-emulator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">download the executable from here</a> and install it on your Windows OS, if you’re running Linux or macOS or want to run it in a docker container please refer to <a href=\"https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=cli%2Cssl-netstd21#run-on-windows-docker\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">the official documentation</a>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4de7592b693bf405cbfca0e60aeb55dc/d8309/em.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 81.85185185185185%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAQABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAwAF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAdJERBnl/8QAGRAAAgMBAAAAAAAAAAAAAAAAABMBAgMQ/9oACAEBAAEFAk0E5iciO//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABoQAAICAwAAAAAAAAAAAAAAAACRAjIBIDP/2gAIAQEABj8CrhFIo5xWn//EABsQAAEEAwAAAAAAAAAAAAAAAAABEBEhceHx/9oACAEBAAE/IU08rqfE5diN/9oADAMBAAIAAwAAABBcz//EABYRAQEBAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPxAMn//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EAB4QAAIBAwUAAAAAAAAAAAAAAAERACEx0UFRYeHw/9oACAEBAAE/EMnwxoCzM9E3PJxA1RcACrqoxP/Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Cosmos DB Emulator\"\n        title=\"\"\n        src=\"/static/4de7592b693bf405cbfca0e60aeb55dc/47311/em.jpg\"\n        srcset=\"/static/4de7592b693bf405cbfca0e60aeb55dc/6f81f/em.jpg 270w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/09d21/em.jpg 540w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/47311/em.jpg 1080w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/d8309/em.jpg 1165w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"differences\" style=\"position:relative;\"><a href=\"#differences\" aria-label=\"differences permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Differences</h2>\n<p>As amazing it looks, there are a few differences you need to keep in mind when working with the emulator:</p>\n<ul>\n<li>As I mentioned before the data explorer only supports the SQL API. But you can use all other APIs from within your application using the SDK.</li>\n<li>It only supports a single account with a well known key. You can change the key from command line, but you cannot change it in the explorer.</li>\n<li>For now it only supports provisioning throughput mode only, meaning you can’t use it in serverless mode.</li>\n<li>It does not support core features such as different consistency levels, scaling, replication and performance guaranties.</li>\n<li>Since the client might not be up to date with Azure Cosmos DB service, make sure you always check the <a href=\"https://docs.microsoft.com/en-us/azure/cosmos-db/estimate-ru-with-capacity-planner\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Cosmos DB capacity planner</a> to accurately estimate your required throughput.</li>\n<li>And the minimum ID property size is 256 characters.</li>\n</ul>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>In this short article I just showed you the tip of the iceberg about what the Azure Cosmos DB Emulator has to offer for you. It’s a great utility to be able to develop applications who rely on Azure Cosmos DB locally and has helped me in my pet projects which doesn’t even need to work with a Cosmos DB instance. Keep an eye out for more articles on some use cases this amazing tool can help you with.</p>","timeToRead":3,"frontmatter":{"title":"How much do you know about Azure CosmosDB Emulator? 🧐","unformattedDate":"2020-12-15T00:00:00.000Z","date":"Dec 15, 2020","path":"/cosmos-emulator/","author":"Yaser Adel Mehraban","tags":["azure","showdev","cosmosdb","emulator"],"thumbnail":null}}},{"node":{"id":"aba3b0f4-8b62-51e5-bbdd-4c71f3870a50","html":"<p>If you have ever tried to add responsiveness to your web application you would know it’s difficult or at least takes a while to get it right. As progressive web apps (PWAs) are the first class citizens on many devices with the ability to get installed, it’s even more important to make sure user’s have the best experience possible. But technology advances in a much faster pace. We have now foldable devices like the shiny new <a href=\"https://devblogs.microsoft.com/surface-duo/microsoft-surface-duo-is-released/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft Surface Duo</a> which add more complexity to this equation.</p>\n<!--more-->\n<h2 id=\"problem\" style=\"position:relative;\"><a href=\"#problem\" aria-label=\"problem permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Problem</h2>\n<p>What if you wanted to show your page across two screens without hiding the content under the middle edge? At least for now we don’t have any device with bending glass to be able to not worry about what appears where on the screen.</p>\n<p>In order to continue with this we need a demo application to make sure we’re on the same page. So let’s create one, say we have an image gallery which has 5 columns and someone is looking at it on their brand new Surface Duo:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"61550355664707035000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<div class=&quot;gallery&quot;>\r\n  <div class=&quot;grid&quot;>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=5&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card p-3&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=4&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=3&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=2&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=1&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=7&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=8&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n    <div class=&quot;card&quot;>\r\n      <img\r\n        class=&quot;card-img-top&quot;\r\n        src=&quot;https://picsum.photos/200/200?random=9&quot;\r\n        alt=&quot;Card image cap&quot;\r\n      />\r\n      <div class=&quot;card-body&quot;>\r\n        <h5 class=&quot;card-title&quot;>Card title</h5>\r\n        <p class=&quot;card-text&quot;>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        </p>\r\n        <p class=&quot;card-text&quot;>\r\n          <small class=&quot;text-muted&quot;>Last updated 3 mins ago</small>\r\n        </p>\r\n      </div>\r\n    </div>\r\n  </div>\r\n</div>`, `61550355664707035000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>gallery<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>grid<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=5<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card p-3<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=4<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=3<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=2<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=1<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=7<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=8<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span>\r\n        <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-img-top<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://picsum.photos/200/200?random=9<span class=\"token punctuation\">\"</span></span>\r\n        <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Card image cap<span class=\"token punctuation\">\"</span></span>\r\n      <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-body<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h5</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-title<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Card title<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h5</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          This card has supporting text below as a natural lead-in to\r\n          additional content.\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>card-text<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>small</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-muted<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Last updated 3 mins ago<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>small</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>And in our CSS file we just put a 5 column layout for the card column like so:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"40933825892801815000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`.grid {\r\n  display: grid;\r\n  grid-template-columns: repeat(5, 1fr);\r\n  grid-row: auto;\r\n}`, `40933825892801815000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token selector\">.grid</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">display</span><span class=\"token punctuation\">:</span> grid<span class=\"token punctuation\">;</span>\r\n  <span class=\"token property\">grid-template-columns</span><span class=\"token punctuation\">:</span> <span class=\"token function\">repeat</span><span class=\"token punctuation\">(</span>5<span class=\"token punctuation\">,</span> 1fr<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n  <span class=\"token property\">grid-row</span><span class=\"token punctuation\">:</span> auto<span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Don’t worry too much about the code, you can view the result <a href=\"https://pwa-dual-screen.glitch.me/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">here on Glitch</a>. Now to test how this page looks like you either have to have the device handy, or if you don’t have it like me, just use the <a href=\"https://docs.microsoft.com/en-us/dual-screen/android/emulator/surface-duo-download?tabs=windows\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Surface Duo Emulator</a> which I find really cool. For example, here is how the page looks like at the moment:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1024px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5ea050377c298584b4ebdbf76110ecc0/2bef9/before.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.81481481481481%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADM0lEQVR42mWTX0zbVRTHf6/GN190zkh0xvkyp9kSZ8iyB43RqNmf6BaXvanbg7olOiYpGzIrMgbI3MoKFtJ12v1RUGBQMuiftbQw0KkJ2jhwDgobUPpntPyglPb38d7bsAc9yTf33HPuOff81TweD6FQiIHBQYLiDAQC+P1+gsEgQ0NDhMNhTCYTFRUVjIyMKPnAwICyWYXP5yM4GKA/1I+2vLxMLp/HAPLiXFlZQclyOQVJDocDp9Op+IWFBaHPCM7AMArIGzn02RwrKQMtFosxNjpKZGJcYILZaJREIkF0Lsac0N2ZmaG6pobPzWYmp6aYmY0SSyQLzkQAup4RrvNEx3Ri4/No1zxXaakqpe7YJ9Qe/ZjwHyOcc7YLBydwdbuwNJ5l06bNbCkuxlx1gq62Szisp0jG4yKbLB3trZyzn8dma8Lb50Lz9nTwcvFzrH/6KSpLjxDwuCl6vIiitWuoKi+j9up11r72Di/sfo+aVi+/XvMw3NXOVxUmOi86KDv4LpdOfkDJvlc4VV2JFvJ0s2HdI2x59hkO7HuLC85vefKxh9n56jZMnx5mf/VZtDXrefCJjex4v4Q2u5XmL4/y0Z7XOW4q5cXnN7L10Qd4SNM4dPAQ2q3RMM2Wk7Q01GITqfx18yZ+n5froQCjY2P4+9zsfGM7u3e9TXvrj1z+rpm6L8qwnK7D5fbS3Gil8rNyzOXH6OvtRZOdTd5LsZTJqC7KYuuLS6LYS6rrkpq+sd3v8qLQpdK60BnqLu1S6QVlJ0mTY3J3epop0UFd15WT27fHGZ+IqKJLqq+v54zFovhEPEEkEmFadF+OVTKZZHJykmh0TtlqUhgXj9LpNJlMRs1jQoxFWvyaNwoRWq1W7HZ7YQ7Fu1RKZLRUyCAl7nLMpL30pclQZZQS8oG8L2ezZAWkTJKlwUpjk03x8eQ80cQ9kvNpUZqM+NRQWC2Xxn9ICuXmrG5JbUsv6zbvYMPWPZgburD3BDnd2c95zxChP//GyC6KhfiHoNvF7zd+/r/DVVLrmMtyuecGL+3az5t7P+RC9zA/tH3PFXcfgV9+49bUXYZ9nXQ6z/D18RKudPzEv3hkVs/3QJxYAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Initial state of the application across two folds\"\n        title=\"\"\n        src=\"/static/5ea050377c298584b4ebdbf76110ecc0/2bef9/before.png\"\n        srcset=\"/static/5ea050377c298584b4ebdbf76110ecc0/01bf6/before.png 270w,\n/static/5ea050377c298584b4ebdbf76110ecc0/07484/before.png 540w,\n/static/5ea050377c298584b4ebdbf76110ecc0/2bef9/before.png 1024w\"\n        sizes=\"(max-width: 1024px) 100vw, 1024px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>You can see right away that it’s not a good look, I mean who would be willing to spend a second on this site? So how do we fix it? I think we’re now on the same page, so let’s dive in.</p>\n<h2 id=\"solution\" style=\"position:relative;\"><a href=\"#solution\" aria-label=\"solution permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Solution</h2>\n<p>But don’t you worry, we’ve got you covered by two brand new experimental APIs that will enable you to effectively lay your elements on the screen where you want them to be.</p>\n<ul>\n<li><a href=\"https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/Foldables/explainer.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">CSS screen-spanning media feature</a></li>\n<li><a href=\"https://github.com/webscreens/window-segments/blob/master/EXPLAINER.md\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">JavaScript window segments enumeration API</a></li>\n</ul>\n<p>The former along with a set of environment variables allows you to be aware of the geometry of the fold. The latter is an API which can be used alongside the media feature to work with non-DOM targets like Canvas 2D and WebGL.</p>\n<h2 id=\"detecting-display-regions\" style=\"position:relative;\"><a href=\"#detecting-display-regions\" aria-label=\"detecting display regions permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Detecting display regions</h2>\n<p>As I mentioned earlier, the <code class=\"language-text\">**screen-spanning**</code> media feature allows you to be aware of the fact that the page is spanned across multiple display regions. But how do we use it? Let’s have a look at the syntax. At its core, you will have the ability to use the below media query:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"62393217295492390000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@media (screen-spanning: <value>) { }`, `62393217295492390000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token atrule\"><span class=\"token rule\">@media</span> <span class=\"token punctuation\">(</span><span class=\"token property\">screen-spanning</span><span class=\"token punctuation\">:</span> &lt;value><span class=\"token punctuation\">)</span></span> <span class=\"token punctuation\">{</span> <span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>The allowed values are:</p>\n<ul>\n<li><strong>single-fold-vertical</strong>: which describes the state of the viewport, when it’s spanning across a single fold and the fold’s posture is vertical. This would mean the device is in double portrait mode like below:</li>\n</ul>\n<p align=\"center\">\n  <span class=\"gatsby-resp-image-wrapper\" style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 450px; \">\n      <a class=\"gatsby-resp-image-link\" href=\"/static/99d6bb43a607c28986686147482caa73/20e5d/double-portrait.jpg\" style=\"display: block\" target=\"_blank\" rel=\"noopener\">\n    <span class=\"gatsby-resp-image-background-image\" style=\"padding-bottom: 62.96296296296296%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAANABQDASIAAhEBAxEB/8QAGAAAAwEBAAAAAAAAAAAAAAAAAAEDAgX/xAAWAQEBAQAAAAAAAAAAAAAAAAABAAL/2gAMAwEAAhADEAAAAe3ma0XEF//EABsQAAEEAwAAAAAAAAAAAAAAAAEAAhAREhMh/9oACAEBAAEFAgONEbKWdJpsf//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABcQAAMBAAAAAAAAAAAAAAAAAAAQEYH/2gAIAQEABj8CNUip/8QAGxAAAgMAAwAAAAAAAAAAAAAAAAERIUExUWH/2gAIAQEAAT8hRChDTrQqmCXAoT5XZNej/9oADAMBAAIAAwAAABBDH//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8QP//EABYRAQEBAAAAAAAAAAAAAAAAAAEAEf/aAAgBAgEBPxDGW//EABsQAQACAwEBAAAAAAAAAAAAAAEAESExcUFR/9oACAEBAAE/EGshUllhwZ7DY4F6OE9I0u4Ql1rt9bjMAXocJ//Z'); background-size: cover; display: block;\"></span>\n  <img class=\"gatsby-resp-image-image\" alt=\"double portrait\" title=\"\" src=\"/static/99d6bb43a607c28986686147482caa73/20e5d/double-portrait.jpg\" srcset=\"/static/99d6bb43a607c28986686147482caa73/6f81f/double-portrait.jpg 270w,\n/static/99d6bb43a607c28986686147482caa73/20e5d/double-portrait.jpg 450w\" sizes=\"(max-width: 450px) 100vw, 450px\" style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\" loading=\"lazy\" decoding=\"async\">\n  </a>\n    </span> <br>\n  <i>Image from Microsoft Surface Duo blog</i>\n</p>\n<p>The code for this mode would be:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"11770771877863928000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@media (screen-spanning: single-fold-vertical) { \r\n  /* styles applied in double-portrait (wide) mode */ \r\n}`, `11770771877863928000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token atrule\"><span class=\"token rule\">@media</span> <span class=\"token punctuation\">(</span><span class=\"token property\">screen-spanning</span><span class=\"token punctuation\">:</span> single-fold-vertical<span class=\"token punctuation\">)</span></span> <span class=\"token punctuation\">{</span> \r\n  <span class=\"token comment\">/* styles applied in double-portrait (wide) mode */</span> \r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<ul>\n<li><strong>single-fold-horizontal</strong>: which describes the state of the viewport, when it’s spanning across a single fold but this time the posture is horizontal. This would match the double portrait tall mode like below:</li>\n</ul>\n<p align=\"center\">\n  <span class=\"gatsby-resp-image-wrapper\" style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 307px; \">\n      <a class=\"gatsby-resp-image-link\" href=\"/static/b917f426d014c89db872985296381bbe/6bde8/double-portrait-tall.jpg\" style=\"display: block\" target=\"_blank\" rel=\"noopener\">\n    <span class=\"gatsby-resp-image-background-image\" style=\"padding-bottom: 140.74074074074073%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAcABQDASIAAhEBAxEB/8QAGQAAAwADAAAAAAAAAAAAAAAAAAECAwQF/8QAFgEBAQEAAAAAAAAAAAAAAAAAAgAB/9oADAMBAAIQAxAAAAHtOGssAyrFCtgA3//EABsQAAICAwEAAAAAAAAAAAAAAAACAREQEjEh/9oACAEBAAEFAqKgUujYTkYUbybkXn//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/AR//xAAYEQACAwAAAAAAAAAAAAAAAAAAARARIf/aAAgBAgEBPwHRlR//xAAbEAACAgMBAAAAAAAAAAAAAAABEAAhAjFxMv/aAAgBAQAGPwIs0Z5yR6j2UZtf/8QAHxABAAIBAwUAAAAAAAAAAAAAAQARMRAhQWFxobHh/9oACAEBAAE/IQKk5nSmL3l0Lt8kv8orTVb4Z7mos1mm8s//2gAMAwEAAgADAAAAEPM9A//EABcRAQEBAQAAAAAAAAAAAAAAAAABETH/2gAIAQMBAT8Q2JxqP//EABgRAAMBAQAAAAAAAAAAAAAAAAABMREh/9oACAECAQE/EGhRp9HT/8QAIBABAAIABQUAAAAAAAAAAAAAAQARITFhkdEQUXGx8f/aAAgBAQABPxC7E3LWafdgozIYQJMfwCvc+M5llKz7h1DL5IigC3VHE1uxxDQVVSqz/9k='); background-size: cover; display: block;\"></span>\n  <img class=\"gatsby-resp-image-image\" alt=\"double portrait tall\" title=\"\" src=\"/static/b917f426d014c89db872985296381bbe/6bde8/double-portrait-tall.jpg\" srcset=\"/static/b917f426d014c89db872985296381bbe/6f81f/double-portrait-tall.jpg 270w,\n/static/b917f426d014c89db872985296381bbe/6bde8/double-portrait-tall.jpg 307w\" sizes=\"(max-width: 307px) 100vw, 307px\" style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\" loading=\"lazy\" decoding=\"async\">\n  </a>\n    </span> <br>\n  <i>Image from Microsoft Surface Duo blog</i>\n</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"93912988246759110000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@media (screen-spanning: single-fold-horizontal) {\r\n   /* styles applied in double-landscape (tall) mode */\r\n}`, `93912988246759110000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token atrule\"><span class=\"token rule\">@media</span> <span class=\"token punctuation\">(</span><span class=\"token property\">screen-spanning</span><span class=\"token punctuation\">:</span> single-fold-horizontal<span class=\"token punctuation\">)</span></span> <span class=\"token punctuation\">{</span>\r\n   <span class=\"token comment\">/* styles applied in double-landscape (tall) mode */</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"environment-variables\" style=\"position:relative;\"><a href=\"#environment-variables\" aria-label=\"environment variables permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Environment variables</h2>\n<p>To get the geometry of the device fold, you could leverage the browser environment variables. You have access to four environment variables:</p>\n<ul>\n<li>fold-top</li>\n<li>fold-left</li>\n<li>fold-width</li>\n<li>fold-height</li>\n</ul>\n<p>The picture below would nicely show you what there values represent:</p>\n<p align=\"center\">\n  <span class=\"gatsby-resp-image-wrapper\" style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1024px; \">\n      <a class=\"gatsby-resp-image-link\" href=\"/static/b7baf799e52328c2f552073e549b35e4/2bef9/env-variables.png\" style=\"display: block\" target=\"_blank\" rel=\"noopener\">\n    <span class=\"gatsby-resp-image-background-image\" style=\"padding-bottom: 78.88888888888889%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3ElEQVR42q2UW2/TQBCF8/9/QN+hqLRSH5om6iXlJipBqQkukAoqlQcQimsnjr2O92Z79zBrp3WilAdQIh3Fm3Pm02y8sx1s9qM7f3PKQkPwHFJwaK2hhKTnHFopWGtXsvYxYFEBibRIF5pkGneJIEmkuUTCFYKZQMQUEmEecq6mqBqkcUCzwJ/eaHRHgr4lTr5LnJIGN4rWAv3+GN1zhhe3mtaq9usMZQ+vBY6/qZpRGQLed9/7IsGoE6UVpGokpKa95+gd/MbLs4nbEbhsfZfNOEE/i6bDZeDhtcR0LjGngkw0YlzTfynQPQkweBPDGo2Ut77LxlTjdrYOHEnEmUROoblolAmNLJ2iexTgjIAgIOOt77KzfwWGwS8cHI03B4wn4812yJKIgP/RYY9+jFJBBc25q88ehZXiNXDwekovqAHc+y47YeJxYJ/eMlcaVVWgLBsVZUljINE/DvDq7cwdf+ii9SuSpCnqrQMNdjyGJ+9j7Hkxdi9b7XlTbO38wPbuT+z7CZ5/WPZiPKWaZ5dpPYA10D0ZY2wYRtbzR/bio0+6etA778oOP5GGvj2/GK54Tp7/1d6FoV3Mt+osj7jbgrsUluUuB8YYKcU8Y2sZt7bWrFwO6YbESNEfIWe+R5no2JIAAAAASUVORK5CYII='); background-size: cover; display: block;\"></span>\n  <img class=\"gatsby-resp-image-image\" alt=\"env variables\" title=\"\" src=\"/static/b7baf799e52328c2f552073e549b35e4/2bef9/env-variables.png\" srcset=\"/static/b7baf799e52328c2f552073e549b35e4/01bf6/env-variables.png 270w,\n/static/b7baf799e52328c2f552073e549b35e4/07484/env-variables.png 540w,\n/static/b7baf799e52328c2f552073e549b35e4/2bef9/env-variables.png 1024w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\" loading=\"lazy\" decoding=\"async\">\n  </a>\n    </span> <br>\n  <i>Image from Microsoft Surface Duo blog</i>\n</p>\n<h2 id=\"\" style=\"position:relative;\"><a href=\"#\" aria-label=\" permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a></h2>\n<p>So let’s see how we can use these features to improve our user experience a bit. First we know that we’re using the <strong><code class=\"language-text\">single-fold-vertical</code></strong> mode, so we’ll add the relevant media query and play with the column count trying to either put the columns in the left or the right side of the fold:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"24559304890794586000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@media (screen-spanning: single-fold-vertical) { \r\n.card-columns { \r\n  grid-template-columns: repeat(4, calc( env(fold-left) /2 - 10px) ); \r\n  } \r\n}`, `24559304890794586000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token atrule\"><span class=\"token rule\">@media</span> <span class=\"token punctuation\">(</span><span class=\"token property\">screen-spanning</span><span class=\"token punctuation\">:</span> single-fold-vertical<span class=\"token punctuation\">)</span></span> <span class=\"token punctuation\">{</span> \r\n<span class=\"token selector\">.card-columns</span> <span class=\"token punctuation\">{</span> \r\n  <span class=\"token property\">grid-template-columns</span><span class=\"token punctuation\">:</span> <span class=\"token function\">repeat</span><span class=\"token punctuation\">(</span>4<span class=\"token punctuation\">,</span> <span class=\"token function\">calc</span><span class=\"token punctuation\">(</span> <span class=\"token function\">env</span><span class=\"token punctuation\">(</span>fold-left<span class=\"token punctuation\">)</span> /2 - 10px<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n  <span class=\"token punctuation\">}</span> \r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<blockquote>\n<p>💡 In order to access these features, you must enable experimental platform features on Edge by visiting <strong><code class=\"language-text\">edge://flags/#enable-experimental-web-platform-features</code></strong> and enabling them.</p>\n</blockquote>\n<p>After setting the column count to 4, we will end up with something like this:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1024px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/c3660014b26c5df5cdd7fd768b727d33/2bef9/semi-aligned.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.81481481481481%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADZUlEQVR42jWTf0zUZRzHv1tbf2T/9l+mJisn5aJEslqb0A9NTGlDREFOLGuSjUlsmjLzlF/eQqh2XB3e8dPZBNoyaWvQwgx/wRXcsk4QbhcH3HHHwf3gfvA9Xj3PN/1snz3vPfs878/z7PN6FJfLhd/vJxgKEpif17TP5yMQCBAOh5FhNBppamrStNxfWFhgXtQ+TK/Xq52ZmZlBCYdDLC5GiMaiRKNRTUsjqWOxmGZiNptpbW3VdDAUIhaPs7S0pKWqqlqd1MlkEsXnD3B/bAL35BRu9zTT016RM/w7Ocnk1BQhYW4ymTAYDMzNzeFw3GN0dJR4PCaaLxISDSKRiLZKY2XYs0RFf5D6a37aBjxcsgUZcTiZmJhgfMIpnjHL10YTac8/R9lHOs6U5FC0awt11Xr27MnlmXUpbExPY9WalZwz1KJcv+chz2wjr8vJjtb77PxikLauq9hH7IyOjTNw4xYVp/Ssfmol+bu2c7xoK3lvbORE2RFey87h8bUbWJWRxWNr1nOyShj+5XBQpS8n9/xlHvlskCf3X6b2fCN37gwy9Ied6poaig9+wLNrV3NIt5sDeW+hy93KyfJPeK9gH2mvbCIr+x0yXn2J+i/rUMb+GaKtsYLO9gZSCit5QhgePa6nWLePko9LyMx8ndTUdbycsZnaSj3HSos5fGAvJz4tJX1TGoqisGLFo9paVlaK4p50cvPGdZxjw3R2f0dDRz9Xf/qZczVnBS5f0d7WQkHhXj4/XcXdv8e5PXAT+6ANu20Ic9O36M+epr6hjsrqM/T90ociRz0762MusCCmFCepJgQCqmAtKPCJaKi0tLRgsVhQBRqSQ4mOrJFTlTqeSJAQuby8jKKqS8LQi8fjxS+wkIzFRc4KUOWejObmZi5YLqCKAx4BsURJTaoaKl5xGQm1ZFfjULomH6TUMiSksrP8OdoNpaG1+X+w54MkEyrLAuhoNEbkwSd4CLmyGAnya4+VW/3d/Hm7F/+si2/MJjK3ZVF06CD5ugLWv5BKYXY+3aV67oqB2Roacff2sS1nO+lbNvCu7k1SXnyaSkMlSiQUoLfnIr3XRvjtd5v4yzNc6fkRo6kRi9WCtdnK2zt3UCPQcf3wPc7Oi7i7OogMD1B+7AjvH97N0VMfsl+XQ3uHhf8AA7EptbMAzswAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Half aligned with columns reducing from 5 to 4\"\n        title=\"\"\n        src=\"/static/c3660014b26c5df5cdd7fd768b727d33/2bef9/semi-aligned.png\"\n        srcset=\"/static/c3660014b26c5df5cdd7fd768b727d33/01bf6/semi-aligned.png 270w,\n/static/c3660014b26c5df5cdd7fd768b727d33/07484/semi-aligned.png 540w,\n/static/c3660014b26c5df5cdd7fd768b727d33/2bef9/semi-aligned.png 1024w\"\n        sizes=\"(max-width: 1024px) 100vw, 1024px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>So we’re one step close to have a better view, but we have the two middle columns right on the fold, and the title is spanning across too. Let’s fix the title first. We could simply set a width for it to be in the first fold, or we could give it a margin right calculating where the fold is located. Let’s use the margin solution.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"60460499881262370000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`h1 { \r\n  margin-right: calc( 100vw - (env(fold-left) + env(fold-width)) ); \r\n}`, `60460499881262370000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token selector\">h1</span> <span class=\"token punctuation\">{</span> \r\n  <span class=\"token property\">margin-right</span><span class=\"token punctuation\">:</span> <span class=\"token function\">calc</span><span class=\"token punctuation\">(</span> 100vw - <span class=\"token punctuation\">(</span><span class=\"token function\">env</span><span class=\"token punctuation\">(</span>fold-left<span class=\"token punctuation\">)</span> + <span class=\"token function\">env</span><span class=\"token punctuation\">(</span>fold-width<span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span> \r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>Here we’re calculating the width of the second fold and setting that as margin right for our header. Of course there are many other ways to achieve this, but I wanted to demonstrate the use of environment variables. After applying the above styles, we will end up with below, which is one step ahead to have a better UX.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1024px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4dccb45080ad712cba8ff5e125560c2a/2bef9/aligned.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.81481481481481%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADTElEQVR42n2TXWxTZRjHz50x4cYbryRcIUYdUSLLiCQmfmTG8bE5XFyjbpqAkZgwx8bYCAQTCSbMqVHrate1tVpxTFQ6yigbZQKyqUO2lanRQem6fq09/e45Xdv9PO+JF1z5T568/+e8z/95npP8XykQCJBIJMhkMyRTKZ3H43GSySS5XA4Bo9GI2WzWubhPaXV3RywW0zWRSARJiAqFAoqq6iF4NptDUVRULRcQzex2u87z+bz+/e4QPRRFoVwuI8myjN/vJxhcYjEYJBQKEY0tE47GiGihqEX6TSacTqfeUIj+D1JCTjLn+4N/Fm6zcDvAUihCsZAnKy9TyKT1IssX/fQPWhGtoukMy9ofpLWNookUi7EEwWWZQCRBMptH8oz9xPM7Wmnd3cX+/Ud5v3cA19BXeC3Hmf6mj8BFB++9ZaCpex/GyVFOXBim2+XEOnmJJwwHkGqaua/2TaTHd9Hx6ddIP5xxs2XL0xjq62nc1kBLy14cVjOnB07w+xk7U99+RGv9Mxw50Mz5sx/ymfEQp5xHuHblJI80tiE9uo01TzYjra/lnd5BpPMeLy9tf5HXGxuoq91OR3sPVtPH9PXs5qqzj6uOYxh2PEV7ax29h9/mDcPLHNprYMploqa5nTVrq1n34FakDc/S+YEFacTlpmrjZqqrt7Lp4Sp27Wzi6LHDvPpKLe17dtKxp46azevZ8FAVLQ11NL3wHJseq+ZgZ5dW+xqSdD/33rOWdQ9spOf4J0iLgUW+Gz7NyIgbj2eciUsTTP72C0M/DjN6wc3MzK90dnXQfbCb+emfmbg4hndsjLkbNzh3bhzbl0MMf+/m5CkX07PzSJVKRfNdVvfTysqKbgsRmUxW96OA8KDNZtN5Ll9ALRYpa7qiduZzeUqaTmhXV1eRSqWS5vAooXAY4UlRpKiK5sEoce1VCFitViwDZlaKqu5TtaANWq2Q0oZGYnFiCZlsXhi7om2odS39t5WYICDyVCqNz+fTc4fDgcliR9wmswWCKZVoRkFJyyQjS6SjQUo5mUpZRRKCmzdnmfB6GHLacLvPUqrA/J9/07avjYVbfswDg7zb+zm+sMro9TsMXvYzOhfmzl/Xmbk2zq1ZL3J4iqIS419hR0Qzjab1/wAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Header aligned with using margin calculated based on fold size\"\n        title=\"\"\n        src=\"/static/4dccb45080ad712cba8ff5e125560c2a/2bef9/aligned.png\"\n        srcset=\"/static/4dccb45080ad712cba8ff5e125560c2a/01bf6/aligned.png 270w,\n/static/4dccb45080ad712cba8ff5e125560c2a/07484/aligned.png 540w,\n/static/4dccb45080ad712cba8ff5e125560c2a/2bef9/aligned.png 1024w\"\n        sizes=\"(max-width: 1024px) 100vw, 1024px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Now is the time to fix the two middle columns. One way to fix the middle column problem is to add an empty column which has no content. But it’s easier said than done. If you’re willing to play with the width of the columns, you can get away with something like this:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"54052915352809430000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`@media (screen-spanning: single-fold-vertical) {\r\n  .grid {    \r\n    grid-template-columns: repeat(4, 23%);\r\n    grid-gap: 25px;\r\n  }\r\n  .card:nth-child(4n + 2) {\r\n    margin-right: 5px;\r\n  }\r\n  .card:nth-child(4n + 3) {\r\n    margin-left: 10px;\r\n  }\r\n}`, `54052915352809430000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token atrule\"><span class=\"token rule\">@media</span> <span class=\"token punctuation\">(</span><span class=\"token property\">screen-spanning</span><span class=\"token punctuation\">:</span> single-fold-vertical<span class=\"token punctuation\">)</span></span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token selector\">.grid</span> <span class=\"token punctuation\">{</span>    \r\n    <span class=\"token property\">grid-template-columns</span><span class=\"token punctuation\">:</span> <span class=\"token function\">repeat</span><span class=\"token punctuation\">(</span>4<span class=\"token punctuation\">,</span> 23%<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token property\">grid-gap</span><span class=\"token punctuation\">:</span> 25px<span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token selector\">.card:nth-child(4n + 2)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">margin-right</span><span class=\"token punctuation\">:</span> 5px<span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n  <span class=\"token selector\">.card:nth-child(4n + 3)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">margin-left</span><span class=\"token punctuation\">:</span> 10px<span class=\"token punctuation\">;</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>This will result in:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1024px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/3a6fefcc61860b93d168b01cf2a90650/2bef9/half-aligned.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 64.81481481481481%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADF0lEQVR42n2TTUxUVxTH38q46Zak7hoauyDRjcFFAyHR1LQaacrChQlpm5J+LHQlKqEapQoRUgIxQxNghhmYSFEEhvAhhmDwYwA/OswosZHawjDO+IaZeW++38DMr/e+icRuepKbe+557/7vOff8ruL3+9nc3CSeSBCNaUSEL9exWIxkMok0i8VCd3e36UciETRN+89QVdXcEwqFUOSmdDpNJps1RyqVMoUymQxZsZbW3dNDX1+f6adSxW/vj4RIRmpsbW2haLqO3/+GYEgl9LY4ZHbyxHA4TC63hc1mw+l0moLb29v8n4kM4wQ2/iYUXBeiAVGSStrIkcgaZMQszdHfL0ruknLiMJVoVCWux1h9tcry8gt8vhW8nuciFkdJ6wFW/xjFe38AbW0Osq8ZujNHs+Mmw48e83xTo6nDQsvVs2z4H+PxzLC0NMqi+w4VByrYvetD9pR8zOH9nzAxOony0rPAb20NDNvbmL/VytqTEa5ct3P8pwYaLU6ssx6+b2jGbu2Egrj4gJfA2gK+5YfUffk5ZaVlHK6q5Ny3NYwPj6N43XN0tZzF0vYzltZzPLh7i3ZbM1/UVfJ141d811pL1YlDdHVeJhxc5Kl7ENfNFqYnnNTXnaTm6FEunz9N7bEjuEzBZwtcb7vA1Yv1NDWcYnrkBpd+/YHyYx9w/Ju9VP9YSvlnH9F+rZHQhpvlJ2PMTnZxd+p39u+roKRkL1UHK6j+tJyJsaliU9b/+Yuw+gYtGkaPRc3m+FY8vHr9J/GkRkdnB729PaLDOXRdwzAyApMUz556ePRQlO/xsbqygiY4ViQGmhYXYCfR4wlygiWJioxpMd3scr/ostVqFYJ5Aa+6A7zkNJ1Jm3NWEFEoFFAkjFHBXUwQL+HM5/MC0Jz5cuQrkGZ32OkVgtKkmPxHbo6LBCKRKJJlwzDMuCI/SCefL+zAWVznTfJNDh0OBgYGTP9dTO57f37nK8GgX4C9ji5Kdi8tMDM7Y5ZmGPK+iiXbbHZ+aTrDg3kXI8N2ZqaHBI+LDA4O0T/k4vbkPW64ZvEHw/wL8+Nxh5KXN5MAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Columns aligned on the two sides of the fold\"\n        title=\"\"\n        src=\"/static/3a6fefcc61860b93d168b01cf2a90650/2bef9/half-aligned.png\"\n        srcset=\"/static/3a6fefcc61860b93d168b01cf2a90650/01bf6/half-aligned.png 270w,\n/static/3a6fefcc61860b93d168b01cf2a90650/07484/half-aligned.png 540w,\n/static/3a6fefcc61860b93d168b01cf2a90650/2bef9/half-aligned.png 1024w\"\n        sizes=\"(max-width: 1024px) 100vw, 1024px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>You can see we’ve come a long way from having a completely spanned content to a neat ordered view. But that’s all have been using only the CSS media feature. Let’s see what does the Window Segment Enumeration API have to offer.</p>\n<h2 id=\"window-segments-enumeration-api\" style=\"position:relative;\"><a href=\"#window-segments-enumeration-api\" aria-label=\"window segments enumeration api permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Window Segments Enumeration API</h2>\n<p>This API helps you to deal with non-DOM elements such as a canvas or WebGL objects. You can leverage the <code class=\"language-text\">getWindowSegments()</code> function which is accessible on the window object and returns an array of one or more <em>DOMRect</em> representing the geometry of and position of each display region:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"94161485213198580000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const segments = window.getWindowSegments();\r\n\r\n// case 1: desktops, traditional touch screen devices, foldable device not spanned\r\nconsole.log(segments.length) // 1\r\n\r\n// case 2: dual-screen and foldable \r\nconsole.log(segments.length) // 2`, `94161485213198580000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">const</span> segments <span class=\"token operator\">=</span> window<span class=\"token punctuation\">.</span><span class=\"token function\">getWindowSegments</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n<span class=\"token comment\">// case 1: desktops, traditional touch screen devices, foldable device not spanned</span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>segments<span class=\"token punctuation\">.</span>length<span class=\"token punctuation\">)</span> <span class=\"token comment\">// 1</span>\r\n\r\n<span class=\"token comment\">// case 2: dual-screen and foldable </span>\r\nconsole<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span>segments<span class=\"token punctuation\">.</span>length<span class=\"token punctuation\">)</span> <span class=\"token comment\">// 2</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>If you wanted to know the fold posture inside your JavaScript code, you can calculate them easily using below snippet:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"44254983286788055000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`function isSingleFoldHorizontal() {\r\n    const segments = window.getWindowSegments();\r\n    if( segments.length !== 2 ) {\r\n        return false;\r\n    }\r\n    if( segments[0].top < segments[1].top ) {\r\n        return true;\r\n    }\r\n    return false;\r\n}`, `44254983286788055000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">function</span> <span class=\"token function\">isSingleFoldHorizontal</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token keyword\">const</span> segments <span class=\"token operator\">=</span> window<span class=\"token punctuation\">.</span><span class=\"token function\">getWindowSegments</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span> segments<span class=\"token punctuation\">.</span>length <span class=\"token operator\">!==</span> <span class=\"token number\">2</span> <span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">return</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n    <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span> segments<span class=\"token punctuation\">[</span><span class=\"token number\">0</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>top <span class=\"token operator\">&lt;</span> segments<span class=\"token punctuation\">[</span><span class=\"token number\">1</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">.</span>top <span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">return</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n    <span class=\"token keyword\">return</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Here we’re simply retuning false if the segments are now two, then check whether the top value of segment 0 is less than segment 1 which means the device is in horizontal state. If not we’re returning false which means it’s vertical posture.</p>\n<h2 id=\"where-to-start\" style=\"position:relative;\"><a href=\"#where-to-start\" aria-label=\"where to start permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Where to start?</h2>\n<p>You can access the CSS screen-spanning media features using the <a href=\"edge://flags/#enable-experimental-web-platform-features\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">experimental web platform feature flag</a>, and the JavaScript Window Segments Enumeration API is accessible by enabling the <a href=\"edge://flags/#enable-javascript-harmony\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Experimental JavaScript flag</a>.</p>\n<p>You also have the option of using Origin Trials, where you can acquire tokens and safely experiment with these new primitives in production in exchange for providing feedback about the APIs. <a href=\"https://developer.microsoft.com/en-us/microsoft-edge/origin-trials/dual-screen-and-foldable-devices-css-and/detail/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Sign up for an Origin Trial if you’re interested in testing out these APIs!</a></p>\n<p><a href=\"https://glitch.com/edit/#!/pwa-dual-screen\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PS: You can find all the the code on Glitch here.</a></p>","timeToRead":8,"frontmatter":{"title":"Add dual screen support to your applications 💻","unformattedDate":"2020-12-07T00:00:00.000Z","date":"Dec 07, 2020","path":"/dual-screen/","author":"Yaser Adel Mehraban","tags":["webdev","showdev","dual-screen","css-media-features"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAYAAACpUE5eAAAACXBIWXMAAAsTAAALEwEAmpwYAAADZUlEQVR42jWTf0zUZRzHv1tbf2T/9l+mJisn5aJEslqb0A9NTGlDREFOLGuSjUlsmjLzlF/eQqh2XB3e8dPZBNoyaWvQwgx/wRXcsk4QbhcH3HHHwf3gfvA9Xj3PN/1snz3vPfs878/z7PN6FJfLhd/vJxgKEpif17TP5yMQCBAOh5FhNBppamrStNxfWFhgXtQ+TK/Xq52ZmZlBCYdDLC5GiMaiRKNRTUsjqWOxmGZiNptpbW3VdDAUIhaPs7S0pKWqqlqd1MlkEsXnD3B/bAL35BRu9zTT016RM/w7Ocnk1BQhYW4ymTAYDMzNzeFw3GN0dJR4PCaaLxISDSKRiLZKY2XYs0RFf5D6a37aBjxcsgUZcTiZmJhgfMIpnjHL10YTac8/R9lHOs6U5FC0awt11Xr27MnlmXUpbExPY9WalZwz1KJcv+chz2wjr8vJjtb77PxikLauq9hH7IyOjTNw4xYVp/Ssfmol+bu2c7xoK3lvbORE2RFey87h8bUbWJWRxWNr1nOyShj+5XBQpS8n9/xlHvlskCf3X6b2fCN37gwy9Ied6poaig9+wLNrV3NIt5sDeW+hy93KyfJPeK9gH2mvbCIr+x0yXn2J+i/rUMb+GaKtsYLO9gZSCit5QhgePa6nWLePko9LyMx8ndTUdbycsZnaSj3HSos5fGAvJz4tJX1TGoqisGLFo9paVlaK4p50cvPGdZxjw3R2f0dDRz9Xf/qZczVnBS5f0d7WQkHhXj4/XcXdv8e5PXAT+6ANu20Ic9O36M+epr6hjsrqM/T90ociRz0762MusCCmFCepJgQCqmAtKPCJaKi0tLRgsVhQBRqSQ4mOrJFTlTqeSJAQuby8jKKqS8LQi8fjxS+wkIzFRc4KUOWejObmZi5YLqCKAx4BsURJTaoaKl5xGQm1ZFfjULomH6TUMiSksrP8OdoNpaG1+X+w54MkEyrLAuhoNEbkwSd4CLmyGAnya4+VW/3d/Hm7F/+si2/MJjK3ZVF06CD5ugLWv5BKYXY+3aV67oqB2Roacff2sS1nO+lbNvCu7k1SXnyaSkMlSiQUoLfnIr3XRvjtd5v4yzNc6fkRo6kRi9WCtdnK2zt3UCPQcf3wPc7Oi7i7OogMD1B+7AjvH97N0VMfsl+XQ3uHhf8AA7EptbMAzswAAAAASUVORK5CYII="},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/c3660014b26c5df5cdd7fd768b727d33/055f6/semi-aligned.png","srcSet":"/static/c3660014b26c5df5cdd7fd768b727d33/43735/semi-aligned.png 750w,\n/static/c3660014b26c5df5cdd7fd768b727d33/055f6/semi-aligned.png 1024w","sizes":"(min-width: 1024px) 1024px, 100vw"},"sources":[{"srcSet":"/static/c3660014b26c5df5cdd7fd768b727d33/f7ac9/semi-aligned.webp 750w,\n/static/c3660014b26c5df5cdd7fd768b727d33/48bef/semi-aligned.webp 1024w","type":"image/webp","sizes":"(min-width: 1024px) 1024px, 100vw"}]},"width":1024,"height":662}}}}}},{"node":{"id":"5349daad-655e-579a-967b-7956530dc39e","html":"<p>I recently was trying to prepare a demo which involved me having a local MongoDb database. I reviewed a few options and was about to choose one when I remembered I have <a href=\"https://yas.fyi/azcosemu\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Azure Cosmos DB Emulator</a> installed and Cosmos DB supports MongoDb APIs.</p>\n<!--more-->\n<h2 id=\"install-if-you-havent-already\" style=\"position:relative;\"><a href=\"#install-if-you-havent-already\" aria-label=\"install if you havent already permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Install if you haven’t already</h2>\n<p>You will need below requirements to be able to install the emulator:</p>\n<ul>\n<li>Windows Server 2012 R2, Windows Server 2016, 2019 or Windows 8 and 10. Docker on Windows, Linux and macOS is also supported.</li>\n<li>64-bit OS.</li>\n<li>Minimum 2GB RAM.</li>\n<li>At least 10GB available hard disk space.</li>\n</ul>\n<p>If you’ve ticked all of above already, then head <a href=\"https://aka.ms/cosmosdb-emulator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">over here and install the latest version</a>. If you stumbled upon any issues use <a href=\"https://docs.microsoft.com/en-us/azure/cosmos-db/troubleshoot-local-emulator\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">the troubleshooting guide</a> to find out what’s happening.</p>\n<blockquote>\n<p>💡 Make sure you check for updates regularly since each new version might contain new features and bug fixes.</p>\n</blockquote>\n<h2 id=\"starting-the-emulator\" style=\"position:relative;\"><a href=\"#starting-the-emulator\" aria-label=\"starting the emulator permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Starting the emulator</h2>\n<p>Normally you would use the Windows start menu to find your programs and start the application, however, for the emulator to support MongoDB APIs, you will need to pass the <code class=\"language-text\">EnableMongoDbEndpoint</code> argument.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4de7592b693bf405cbfca0e60aeb55dc/d8309/startingthecosmosdbemulator.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 81.85185185185185%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAQABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAwAF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAdJERBnl/8QAGRAAAgMBAAAAAAAAAAAAAAAAABMBAgMQ/9oACAEBAAEFAk0E5iciO//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABoQAAICAwAAAAAAAAAAAAAAAACRAjIBIDP/2gAIAQEABj8CrhFIo5xWn//EABsQAAEEAwAAAAAAAAAAAAAAAAABEBEhceHx/9oACAEBAAE/IU08rqfE5diN/9oADAMBAAIAAwAAABBcz//EABYRAQEBAAAAAAAAAAAAAAAAAAEQEf/aAAgBAwEBPxAMn//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8QP//EAB4QAAIBAwUAAAAAAAAAAAAAAAERACEx0UFRYeHw/9oACAEBAAE/EMnwxoCzM9E3PJxA1RcACrqoxP/Z'); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Starting Azure Cosmos DB Emulator\"\n        title=\"\"\n        src=\"/static/4de7592b693bf405cbfca0e60aeb55dc/47311/startingthecosmosdbemulator.jpg\"\n        srcset=\"/static/4de7592b693bf405cbfca0e60aeb55dc/6f81f/startingthecosmosdbemulator.jpg 270w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/09d21/startingthecosmosdbemulator.jpg 540w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/47311/startingthecosmosdbemulator.jpg 1080w,\n/static/4de7592b693bf405cbfca0e60aeb55dc/d8309/startingthecosmosdbemulator.jpg 1165w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>You have a few options here:</p>\n<ol>\n<li>Create a shortcut and pass the required arguments</li>\n<li>Use command line to start it</li>\n</ol>\n<p>I am going to use <a href=\"https://github.com/microsoft/terminal\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Windows Terminal</a>. Run the below command to fire up the emulator with MongoDB support:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"31531308088081400000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`& 'C:\\Program Files\\Azure Cosmos DB Emulator\\CosmosDB.Emulator.exe' /EnableMongoDbEndpoint`, `31531308088081400000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token operator\">&amp;</span> <span class=\"token string\">'C:\\Program Files\\Azure Cosmos DB Emulator\\CosmosDB.Emulator.exe'</span> /EnableMongoDbEndpoint</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>You will be prompted to approve the emulator making changes to your system and once approved, you will see the emulator starting and the interface will open in your default browser.</p>\n<h2 id=\"getting-the-connection-string\" style=\"position:relative;\"><a href=\"#getting-the-connection-string\" aria-label=\"getting the connection string permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Getting the connection string</h2>\n<p>The very first thing you’d see is the quick start which should look something like this:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/1ded639cfb17580528aea8c832a21acb/57b36/emulatorquickstart.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAKABQDASIAAhEBAxEB/8QAFwABAQEBAAAAAAAAAAAAAAAAAwABBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAei+uDNH/8QAGhAAAgMBAQAAAAAAAAAAAAAAAgMAARMQM//aAAgBAQABBQJYVa8xmYRPjz//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAcEAABAwUAAAAAAAAAAAAAAAACADKRECIxUXH/2gAIAQEABj8CG0caTAhMGEHK/wD/xAAdEAABAgcAAAAAAAAAAAAAAAAAARARITFBobHx/9oACAEBAAE/IVziy1KXgcgYHT//2gAMAwEAAgADAAAAEOAP/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPxA//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAHRABAAEDBQAAAAAAAAAAAAAAAQARYfAQQVHB0f/aAAgBAQABPxA+uVUK1oWnUh8hv41pn+Gv/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Azure Cosmos DB Emulator connection string page\"\n        title=\"\"\n        src=\"/static/1ded639cfb17580528aea8c832a21acb/47311/emulatorquickstart.jpg\"\n        srcset=\"/static/1ded639cfb17580528aea8c832a21acb/6f81f/emulatorquickstart.jpg 270w,\n/static/1ded639cfb17580528aea8c832a21acb/09d21/emulatorquickstart.jpg 540w,\n/static/1ded639cfb17580528aea8c832a21acb/47311/emulatorquickstart.jpg 1080w,\n/static/1ded639cfb17580528aea8c832a21acb/0047d/emulatorquickstart.jpg 1620w,\n/static/1ded639cfb17580528aea8c832a21acb/274e1/emulatorquickstart.jpg 2160w,\n/static/1ded639cfb17580528aea8c832a21acb/57b36/emulatorquickstart.jpg 2425w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>What you’ll need is the <em>Mongo Connection String</em>. Copy that you’ll be ready to kick start. I am going to use the Node sample from the quick start to continue the rest of this guide, but you can use this straight away in your current code.</p>\n<h2 id=\"creating-a-nodejs-web-api-project\" style=\"position:relative;\"><a href=\"#creating-a-nodejs-web-api-project\" aria-label=\"creating a nodejs web api project permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating a Node.js Web API project</h2>\n<p>Open up a command prompt in a new folder and initiate a project:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"19082403483384726000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`npm init -y`, `19082403483384726000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">npm</span> init <span class=\"token parameter variable\">-y</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>The next thing to do is to install the dependencies:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"82629760536939740000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`# linux or macOS\r\ntouch app.js\r\n\r\n# Windows\r\necho &quot;&quot; > app.js\r\n\r\n# install dependencies\r\nnpm install express mongodb body-parser`, `82629760536939740000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token comment\"># linux or macOS</span>\r\n<span class=\"token function\">touch</span> app.js\r\n\r\n<span class=\"token comment\"># Windows</span>\r\n<span class=\"token builtin class-name\">echo</span> <span class=\"token string\">\"\"</span> <span class=\"token operator\">></span> app.js\r\n\r\n<span class=\"token comment\"># install dependencies</span>\r\n<span class=\"token function\">npm</span> <span class=\"token function\">install</span> express mongodb body-parser</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h3 id=\"the-app\" style=\"position:relative;\"><a href=\"#the-app\" aria-label=\"the app permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>The app</h3>\n<p>We would have a simple application, since this tutorial is not a Node.js or Express.js focused, I will just brush on some steps here. Feel free to go through and understand each of these at your own pace.</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"45833356213698440000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const Express = require(&quot;express&quot;);\r\nconst BodyParser = require(&quot;body-parser&quot;);\r\nconst MongoClient = require(&quot;mongodb&quot;).MongoClient;\r\nconst ObjectId = require(&quot;mongodb&quot;).ObjectID;\r\nvar app = Express();\r\napp.use(BodyParser.json());\r\napp.use(BodyParser.urlencoded({ extended: true }));\r\napp.listen(5000, () => {});`, `45833356213698440000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">const</span> Express <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"express\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> BodyParser <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"body-parser\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> MongoClient <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"mongodb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>MongoClient<span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> ObjectId <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"mongodb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>ObjectID<span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">var</span> app <span class=\"token operator\">=</span> <span class=\"token function\">Express</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>BodyParser<span class=\"token punctuation\">.</span><span class=\"token function\">json</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>BodyParser<span class=\"token punctuation\">.</span><span class=\"token function\">urlencoded</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">extended</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">listen</span><span class=\"token punctuation\">(</span><span class=\"token number\">5000</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>What we have here is a simple web server which responds to <code class=\"language-text\">http://localhost:5000</code>. All we’re doing is initializing the <code class=\"language-text\">MongoClient</code> and a web server. Next thing we need to do is to establish a connection with MongoDB interface of our emulator:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"22570903556542990000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`const Express = require(&quot;express&quot;);\r\nconst BodyParser = require(&quot;body-parser&quot;);\r\nconst MongoClient = require(&quot;mongodb&quot;).MongoClient;\r\nconst ObjectId = require(&quot;mongodb&quot;).ObjectID;\r\nconst CONNECTION_URL = &quot;YOUR CONNECTION STRING&quot;;\r\nconst DATABASE_NAME = &quot;cosmos_emulator_mongo&quot;;\r\n\r\n\r\nvar app = Express();\r\napp.use(BodyParser.json());\r\napp.use(BodyParser.urlencoded({ extended: true }));\r\nvar database, collection;\r\n\r\napp.listen(5000, () => {\r\n    MongoClient.connect(CONNECTION_URL, { useNewUrlParser: true }, (error, client) => {\r\n        if(error) {\r\n            throw error;\r\n        }\r\n        database = client.db(DATABASE_NAME);\r\n        collection = database.collection(&quot;celebrities&quot;);\r\n        console.log(&quot;Connected to \\`&quot; + DATABASE_NAME + &quot;\\`!&quot;);\r\n    });\r\n});`, `22570903556542990000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\"><span class=\"token keyword\">const</span> Express <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"express\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> BodyParser <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"body-parser\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> MongoClient <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"mongodb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>MongoClient<span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> ObjectId <span class=\"token operator\">=</span> <span class=\"token function\">require</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"mongodb\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span>ObjectID<span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> <span class=\"token constant\">CONNECTION_URL</span> <span class=\"token operator\">=</span> <span class=\"token string\">\"YOUR CONNECTION STRING\"</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">const</span> <span class=\"token constant\">DATABASE_NAME</span> <span class=\"token operator\">=</span> <span class=\"token string\">\"cosmos_emulator_mongo\"</span><span class=\"token punctuation\">;</span>\r\n\r\n\r\n<span class=\"token keyword\">var</span> app <span class=\"token operator\">=</span> <span class=\"token function\">Express</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>BodyParser<span class=\"token punctuation\">.</span><span class=\"token function\">json</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">use</span><span class=\"token punctuation\">(</span>BodyParser<span class=\"token punctuation\">.</span><span class=\"token function\">urlencoded</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">extended</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token keyword\">var</span> database<span class=\"token punctuation\">,</span> collection<span class=\"token punctuation\">;</span>\r\n\r\napp<span class=\"token punctuation\">.</span><span class=\"token function\">listen</span><span class=\"token punctuation\">(</span><span class=\"token number\">5000</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    MongoClient<span class=\"token punctuation\">.</span><span class=\"token function\">connect</span><span class=\"token punctuation\">(</span><span class=\"token constant\">CONNECTION_URL</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span> <span class=\"token literal-property property\">useNewUrlParser</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span> <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">error<span class=\"token punctuation\">,</span> client</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span>error<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n            <span class=\"token keyword\">throw</span> error<span class=\"token punctuation\">;</span>\r\n        <span class=\"token punctuation\">}</span>\r\n        database <span class=\"token operator\">=</span> client<span class=\"token punctuation\">.</span><span class=\"token function\">db</span><span class=\"token punctuation\">(</span><span class=\"token constant\">DATABASE_NAME</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        collection <span class=\"token operator\">=</span> database<span class=\"token punctuation\">.</span><span class=\"token function\">collection</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"celebrities\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"Connected to `\"</span> <span class=\"token operator\">+</span> <span class=\"token constant\">DATABASE_NAME</span> <span class=\"token operator\">+</span> <span class=\"token string\">\"`!\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>The next thing we do to make it simpler to run the app is to add a start script to our <code class=\"language-text\">package.json</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"76670569593941620000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`&quot;scripts&quot;: {\r\n    &quot;start&quot;: &quot;node app.js&quot;\r\n}`, `76670569593941620000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token property\">\"scripts\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"start\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"node app.js\"</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>If you run <code class=\"language-text\">npm start</code> now, you should see the message connected to <code class=\"language-text\">Connected to 'cosmos_emulator_mongo'</code> printed on your console which means you’ve successfully connected to the MongoDb APIs.</p>\n<h3 id=\"seed-the-database\" style=\"position:relative;\"><a href=\"#seed-the-database\" aria-label=\"seed the database permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Seed the database</h3>\n<p>First let’s create a JSON file which contains some celebrities 😎:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"22104713557967640000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`[{\r\n  &quot;age&quot;: 18,\r\n  &quot;birth_place&quot;: &quot;Harij, Gujarat, India&quot;,\r\n  &quot;birth_sign&quot;: &quot;Pisces&quot;,\r\n  &quot;birth_year&quot;: &quot;1996&quot;,\r\n  &quot;birthday&quot;: &quot;September 28&quot;,\r\n  &quot;name&quot;: &quot;Daxeel Soni&quot;,\r\n  &quot;occupation&quot;: &quot;Developer of this API. More: www.daxeelsoni.in&quot;,\r\n  &quot;photo_url&quot;: &quot;http://daxeelsoni.in/images/me.jpg&quot;\r\n}, {\r\n  &quot;age&quot;: 28,\r\n  &quot;birth_place&quot;: &quot;Houston&quot;,\r\n  &quot;birth_sign&quot;: &quot;Libra&quot;,\r\n  &quot;birth_year&quot;: &quot;1987&quot;,\r\n  &quot;birthday&quot;: &quot;September 28&quot;,\r\n  &quot;name&quot;: &quot;Hilary Duff&quot;,\r\n  &quot;occupation&quot;: &quot;TV Actress&quot;,\r\n  &quot;photo_url&quot;: &quot;http://www.famousbirthdays.com/thumbnails/duff-hilary-medium.jpg&quot;\r\n}, {\r\n  &quot;age&quot;: 38,\r\n  &quot;birth_place&quot;: &quot;Columbia&quot;,\r\n  &quot;birth_sign&quot;: &quot;Libra&quot;,\r\n  &quot;birth_year&quot;: &quot;1977&quot;,\r\n  &quot;birthday&quot;: &quot;September 28&quot;,\r\n  &quot;name&quot;: &quot;Young Jeezy&quot;,\r\n  &quot;occupation&quot;: &quot;Rapper&quot;,\r\n  &quot;photo_url&quot;: &quot;http://www.famousbirthdays.com/thumbnails/jeezy-young-medium.jpg&quot;\r\n}, {\r\n  &quot;age&quot;: 48,\r\n  &quot;birth_place&quot;: &quot;Roanoke&quot;,\r\n  &quot;birth_sign&quot;: &quot;Libra&quot;,\r\n  &quot;birth_year&quot;: &quot;1967&quot;,\r\n  &quot;birthday&quot;: &quot;September 28&quot;,\r\n  &quot;name&quot;: &quot;Challen Cates&quot;,\r\n  &quot;occupation&quot;: &quot;TV Actress&quot;,\r\n  &quot;photo_url&quot;: &quot;http://www.famousbirthdays.com/thumbnails/cates-challen-medium.jpg&quot;\r\n}]`, `22104713557967640000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token punctuation\">[</span><span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"age\"</span><span class=\"token operator\">:</span> <span class=\"token number\">18</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_place\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Harij, Gujarat, India\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_sign\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Pisces\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_year\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1996\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birthday\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"September 28\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Daxeel Soni\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"occupation\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Developer of this API. More: www.daxeelsoni.in\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"photo_url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://daxeelsoni.in/images/me.jpg\"</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"age\"</span><span class=\"token operator\">:</span> <span class=\"token number\">28</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_place\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Houston\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_sign\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Libra\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_year\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1987\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birthday\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"September 28\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Hilary Duff\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"occupation\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"TV Actress\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"photo_url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://www.famousbirthdays.com/thumbnails/duff-hilary-medium.jpg\"</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"age\"</span><span class=\"token operator\">:</span> <span class=\"token number\">38</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_place\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Columbia\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_sign\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Libra\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_year\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1977\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birthday\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"September 28\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Young Jeezy\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"occupation\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Rapper\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"photo_url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://www.famousbirthdays.com/thumbnails/jeezy-young-medium.jpg\"</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"age\"</span><span class=\"token operator\">:</span> <span class=\"token number\">48</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_place\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Roanoke\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_sign\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Libra\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birth_year\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"1967\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"birthday\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"September 28\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"name\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"Challen Cates\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"occupation\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"TV Actress\"</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token property\">\"photo_url\"</span><span class=\"token operator\">:</span> <span class=\"token string\">\"http://www.famousbirthdays.com/thumbnails/cates-challen-medium.jpg\"</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">]</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Now that we have our JSON file, let’s seed the database. Replace the initial connect code with this:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"51872652401542060000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`app.listen(5000, () => {\r\n  MongoClient.connect(\r\n    CONNECTION_URL,\r\n    {\r\n      useNewUrlParser: true,\r\n      sslValidate: false,\r\n    },\r\n    (error, client) => {\r\n      if (error) {\r\n        throw error;\r\n      }\r\n      database = client.db(DATABASE_NAME);\r\n      collection = database.collection(&quot;celebrities&quot;);\r\n      collection.estimatedDocumentCount({}, (erorr, numOfRecords) => {\r\n        if (numOfRecords <= 0) {\r\n          fs.readFile(&quot;./info.json&quot;, &quot;utf8&quot;, (err, data) => {\r\n            if (err) {\r\n              console.log(\\`Error reading file from disk: \\${err}\\`);\r\n            } else {\r\n              // parse JSON string to JSON object\r\n              const celebrities = JSON.parse(data);\r\n\r\n              collection.insertMany(celebrities, (error, result) => {\r\n                if (error) {\r\n                  console.log(\\`Error in saving seed data: \\${error}\\`);\r\n                }\r\n\r\n                console.log(\\`Seed data inserted into the database!\\`);\r\n              });\r\n            }\r\n          });\r\n        } else {\r\n          console.log(\\`Connected to database\\`);\r\n        }\r\n      });\r\n    }\r\n  );\r\n});`, `51872652401542060000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\">app<span class=\"token punctuation\">.</span><span class=\"token function\">listen</span><span class=\"token punctuation\">(</span><span class=\"token number\">5000</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n  MongoClient<span class=\"token punctuation\">.</span><span class=\"token function\">connect</span><span class=\"token punctuation\">(</span>\r\n    <span class=\"token constant\">CONNECTION_URL</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">{</span>\r\n      <span class=\"token literal-property property\">useNewUrlParser</span><span class=\"token operator\">:</span> <span class=\"token boolean\">true</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token literal-property property\">sslValidate</span><span class=\"token operator\">:</span> <span class=\"token boolean\">false</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">(</span><span class=\"token parameter\">error<span class=\"token punctuation\">,</span> client</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>error<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">throw</span> error<span class=\"token punctuation\">;</span>\r\n      <span class=\"token punctuation\">}</span>\r\n      database <span class=\"token operator\">=</span> client<span class=\"token punctuation\">.</span><span class=\"token function\">db</span><span class=\"token punctuation\">(</span><span class=\"token constant\">DATABASE_NAME</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      collection <span class=\"token operator\">=</span> database<span class=\"token punctuation\">.</span><span class=\"token function\">collection</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"celebrities\"</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n      collection<span class=\"token punctuation\">.</span><span class=\"token function\">estimatedDocumentCount</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">erorr<span class=\"token punctuation\">,</span> numOfRecords</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>numOfRecords <span class=\"token operator\">&lt;=</span> <span class=\"token number\">0</span><span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n          fs<span class=\"token punctuation\">.</span><span class=\"token function\">readFile</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"./info.json\"</span><span class=\"token punctuation\">,</span> <span class=\"token string\">\"utf8\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">err<span class=\"token punctuation\">,</span> data</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n            <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>err<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n              console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Error reading file from disk: </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>err<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n            <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n              <span class=\"token comment\">// parse JSON string to JSON object</span>\r\n              <span class=\"token keyword\">const</span> celebrities <span class=\"token operator\">=</span> <span class=\"token constant\">JSON</span><span class=\"token punctuation\">.</span><span class=\"token function\">parse</span><span class=\"token punctuation\">(</span>data<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n\r\n              collection<span class=\"token punctuation\">.</span><span class=\"token function\">insertMany</span><span class=\"token punctuation\">(</span>celebrities<span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">error<span class=\"token punctuation\">,</span> result</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n                <span class=\"token keyword\">if</span> <span class=\"token punctuation\">(</span>error<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n                  console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Error in saving seed data: </span><span class=\"token interpolation\"><span class=\"token interpolation-punctuation punctuation\">${</span>error<span class=\"token interpolation-punctuation punctuation\">}</span></span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n                <span class=\"token punctuation\">}</span>\r\n\r\n                console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Seed data inserted into the database!</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n              <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n            <span class=\"token punctuation\">}</span>\r\n          <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token punctuation\">}</span> <span class=\"token keyword\">else</span> <span class=\"token punctuation\">{</span>\r\n          console<span class=\"token punctuation\">.</span><span class=\"token function\">log</span><span class=\"token punctuation\">(</span><span class=\"token template-string\"><span class=\"token template-punctuation string\">`</span><span class=\"token string\">Connected to database</span><span class=\"token template-punctuation string\">`</span></span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token punctuation\">}</span>\r\n      <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>All we’re doing here is to get the number of records in the collection and if there is nothing, read the JSON file and write it to the collection.</p>\n<p>Don’t forget to add <code class=\"language-text\">const fs = require('fs')</code> at the top with other require statements.</p>\n<p>Now if you run <code class=\"language-text\">npm start</code> would should see the application start and then the <strong>seed data inserted</strong> message.</p>\n<h3 id=\"creating-the-endpoint\" style=\"position:relative;\"><a href=\"#creating-the-endpoint\" aria-label=\"creating the endpoint permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating the endpoint</h3>\n<p>And now all we need is to add our get endpoint to be able to fetch our celebrities. Don’t forget to add it before you create your listener:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"22428041939547304000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`app.get(&quot;/api/celebrities&quot;, (request, response) => {\r\n    collection.find({}).toArray((error, result) => {\r\n        if(error) {\r\n            return response.status(500).send(error);\r\n        }\r\n        response.send(result);\r\n    });\r\n});`, `22428041939547304000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"javascript\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-javascript line-numbers\"><code class=\"language-javascript\">app<span class=\"token punctuation\">.</span><span class=\"token function\">get</span><span class=\"token punctuation\">(</span><span class=\"token string\">\"/api/celebrities\"</span><span class=\"token punctuation\">,</span> <span class=\"token punctuation\">(</span><span class=\"token parameter\">request<span class=\"token punctuation\">,</span> response</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n    collection<span class=\"token punctuation\">.</span><span class=\"token function\">find</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">toArray</span><span class=\"token punctuation\">(</span><span class=\"token punctuation\">(</span><span class=\"token parameter\">error<span class=\"token punctuation\">,</span> result</span><span class=\"token punctuation\">)</span> <span class=\"token operator\">=></span> <span class=\"token punctuation\">{</span>\r\n        <span class=\"token keyword\">if</span><span class=\"token punctuation\">(</span>error<span class=\"token punctuation\">)</span> <span class=\"token punctuation\">{</span>\r\n            <span class=\"token keyword\">return</span> response<span class=\"token punctuation\">.</span><span class=\"token function\">status</span><span class=\"token punctuation\">(</span><span class=\"token number\">500</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">.</span><span class=\"token function\">send</span><span class=\"token punctuation\">(</span>error<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n        <span class=\"token punctuation\">}</span>\r\n        response<span class=\"token punctuation\">.</span><span class=\"token function\">send</span><span class=\"token punctuation\">(</span>result<span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token punctuation\">}</span><span class=\"token punctuation\">)</span><span class=\"token punctuation\">;</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"testing-the-application\" style=\"position:relative;\"><a href=\"#testing-the-application\" aria-label=\"testing the application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Testing the application</h2>\n<p>You’re now ready to get your celebrities via the API. Simply open a browser and head over to <code class=\"language-text\">http://localhost:5000/api/celebrities</code> or just use the below command:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"56628277028816480000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`curl -X GET http://localhost:5000/api/celebrities`, `56628277028816480000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">curl</span> <span class=\"token parameter variable\">-X</span> GET http://localhost:5000/api/celebrities</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>In this guide we saw how to use Azure Cosmos DB Emulator with MongoDb API to have a local MongoDb available for our local development and proof of concepts. Hope this has helped you save some time and also the trouble of installing yet another software on your system (of course if you already are using the emulator 😊).</p>\n<p>Enjoy hacking and let us know what awesome projects you’re doing using the emulator.</p>\n<p>PS: You can find the finished code in my <a href=\"https://github.com/yashints/azure-cosmosdb-emulator-mongodb\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repository here</a>.</p>","timeToRead":5,"frontmatter":{"title":"How to use Azure Cosmos Emulator as a local MongoDb database 🌍","unformattedDate":"2020-11-30T00:00:00.000Z","date":"Nov 30, 2020","path":"/az-cosmos-emulator/","author":"Yaser Adel Mehraban","tags":["azure","cosmosdb","emulator","mongodb"],"thumbnail":null}}},{"node":{"id":"98876b21-77a3-5449-9d49-a72d10a259ee","html":"<p>How many times have you been working on multiple systems and realised you are trying to paste something which you have copied on the other system? Well with the help of this article you can now share your clipboard between your <strong>Windows</strong> and <strong>Mac</strong> devices 😎.</p>\n<!--more-->\n<h2 id=\"windows-to-windows\" style=\"position:relative;\"><a href=\"#windows-to-windows\" aria-label=\"windows to windows permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Windows to Windows</h2>\n<p>If you have multiple windows devices, it’s very easy. Simply open your control panel and search for <em>Clipboard Settings</em>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b63796ebac291e25c796b69897fe398b/7f09e/windows-clipboard.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 71.48148148148148%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAOABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAMF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAde86oC//8QAFxABAAMAAAAAAAAAAAAAAAAAAQAgQf/aAAgBAQABBQIJlP/EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABQQAQAAAAAAAAAAAAAAAAAAACD/2gAIAQEABj8CX//EABoQAQADAAMAAAAAAAAAAAAAAAEAEBExYZH/2gAIAQEAAT8hDv2ZoKAIcV//2gAMAwEAAgADAAAAEK/P/8QAFhEAAwAAAAAAAAAAAAAAAAAAARAR/9oACAEDAQE/EIF//8QAFhEAAwAAAAAAAAAAAAAAAAAAARAR/9oACAECAQE/EKV//8QAGxAAAgIDAQAAAAAAAAAAAAAAABEBIRAxcUH/2gAIAQEAAT8QeWnZQJSWPAslTgz/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Opening clipboard settings on windows\"\n        title=\"\"\n        src=\"/static/b63796ebac291e25c796b69897fe398b/47311/windows-clipboard.jpg\"\n        srcset=\"/static/b63796ebac291e25c796b69897fe398b/6f81f/windows-clipboard.jpg 270w,\n/static/b63796ebac291e25c796b69897fe398b/09d21/windows-clipboard.jpg 540w,\n/static/b63796ebac291e25c796b69897fe398b/47311/windows-clipboard.jpg 1080w,\n/static/b63796ebac291e25c796b69897fe398b/7f09e/windows-clipboard.jpg 1156w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<p>Once opened, set the <strong>Sync across devices</strong> option to on. If you want to prevent sensitive data to be synced and do it on a case by case basis, set the <strong>Never automatically sync text that I copy</strong> option to on instead.</p>\n<p><img src=\"/1c3782258e317f014eda43682c3642ad/clipboard-settings-windows.jpg\" alt=\"Clipboard settings on windows\"></p>\n<p>While you’re at it, turn clipboard history on too to have a beautiful clipboard history available by pressing <kbd>Win</kbd>+<kbd>V</kbd>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 433px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/674b46e8eac0424a0c58915840d6d2dd/3561e/clipboard-history.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 132.96296296296296%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAbABQDASIAAhEBAxEB/8QAGAABAQEBAQAAAAAAAAAAAAAAAgADAQX/xAAVAQEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAAB9dLqYyhaBrlUf//EABsQAAICAwEAAAAAAAAAAAAAAAACATEQEiER/9oACAEBAAEFAtTUnk8k8GtKGvDX/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAwEBPwEf/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPwEf/8QAFBABAAAAAAAAAAAAAAAAAAAAMP/aAAgBAQAGPwJP/8QAGxAAAgMBAQEAAAAAAAAAAAAAAAERIVEQYfD/2gAIAQEAAT8hXyRWFoViSZUkcZ5GNWXvaFnL/9oADAMBAAIAAwAAABAP3QD/xAAVEQEBAAAAAAAAAAAAAAAAAAARIP/aAAgBAwEBPxAj/8QAFBEBAAAAAAAAAAAAAAAAAAAAIP/aAAgBAgEBPxAf/8QAHhAAAwEAAgIDAAAAAAAAAAAAAAERITFRQWGBkfH/2gAIAQEAAT8Q8idoppxd1CKETkgRlxgltOk7hwyMN+4z5J+Bc13BiksfQqSxTD//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Windows clipboard history\"\n        title=\"\"\n        src=\"/static/674b46e8eac0424a0c58915840d6d2dd/3561e/clipboard-history.jpg\"\n        srcset=\"/static/674b46e8eac0424a0c58915840d6d2dd/6f81f/clipboard-history.jpg 270w,\n/static/674b46e8eac0424a0c58915840d6d2dd/3561e/clipboard-history.jpg 433w\"\n        sizes=\"(max-width: 433px) 100vw, 433px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h3 id=\"use-the-copied-text\" style=\"position:relative;\"><a href=\"#use-the-copied-text\" aria-label=\"use the copied text permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Use the copied text</h3>\n<p>Now if you copy something into your clipboard, based on assuming you wanted to sync everything, simply paste, or open your clipboard history on the target device to see it.</p>\n<blockquote>\n<p>⚠️ If you selected never automatically sync option, you can press <kbd>Win</kbd>+<kbd>V</kbd> to open up your clipboard history and select what you want to be synced across your devices after copying the items.</p>\n</blockquote>\n<h3 id=\"additional-tip\" style=\"position:relative;\"><a href=\"#additional-tip\" aria-label=\"additional tip permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Additional tip</h3>\n<p>If you choose to use clipboard history, make sure you pin items you use frequently to save yourself some more time too.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 429px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/5943b22bbb49e2802deb3e2cfd714760/09fc4/pin-history.jpg\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 134.8148148148148%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAbABQDASIAAhEBAxEB/8QAGQAAAgMBAAAAAAAAAAAAAAAAAAIBAwUE/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAdfi0oSkYLWV1rAP/8QAHBAAAwABBQAAAAAAAAAAAAAAAAECAxARITFB/9oACAEBAAEFAtkTWWqfAumho8GLRn//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/AR//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/AR//xAAaEAABBQEAAAAAAAAAAAAAAAAxAAECETAy/9oACAEBAAY/Aipc0wz/AP/EABsQAAIDAQEBAAAAAAAAAAAAAAABESExQVGh/9oACAEBAAE/IVS39i1SSSyd+GC7Ak4JuFmCmFovrN6LRBs//9oADAMBAAIAAwAAABCv6wz/xAAXEQADAQAAAAAAAAAAAAAAAAAAAREQ/9oACAEDAQE/EIR7/8QAFhEAAwAAAAAAAAAAAAAAAAAAABAR/9oACAECAQE/ECv/xAAcEAEBAAMAAwEAAAAAAAAAAAABEQAhMUFRYXH/2gAIAQEAAT8QngL0jWQFmVCqV81VPZktHgv7gBs6LueMRCO/W4wIuec5kISuGmm/M59awo0cyPRhJ0cz/9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Pin items in clipboard history on windows\"\n        title=\"\"\n        src=\"/static/5943b22bbb49e2802deb3e2cfd714760/09fc4/pin-history.jpg\"\n        srcset=\"/static/5943b22bbb49e2802deb3e2cfd714760/6f81f/pin-history.jpg 270w,\n/static/5943b22bbb49e2802deb3e2cfd714760/09fc4/pin-history.jpg 429w\"\n        sizes=\"(max-width: 429px) 100vw, 429px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n  </a>\n    </span></p>\n<h2 id=\"mac-to-mac\" style=\"position:relative;\"><a href=\"#mac-to-mac\" aria-label=\"mac to mac permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Mac to Mac</h2>\n<p>If you’re a Mac user and want to achieve the same, you can use the <a href=\"https://support.apple.com/en-au/HT209460#:~:text=On%20your%20Mac%3A%20Choose%20Apple,Handoff%2C%20then%20turn%20on%20Handoff.\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Universal Clipboard</a>.</p>\n<p>It’s really simple, like we saw on windows setup.</p>\n<h2 id=\"windowsmaclinux-to-macwindowslinux\" style=\"position:relative;\"><a href=\"#windowsmaclinux-to-macwindowslinux\" aria-label=\"windowsmaclinux to macwindowslinux permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Windows/Mac/Linux to Mac/Windows/Linux</h2>\n<p>If you use two different operating systems and want to simply share your content across, nothing works better than <a href=\"https://pastebin.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PASTEBIN</a>.</p>\n<p>This is a web tool that allows you to share your content across different devices with ease.</p>\n<h2 id=\"warning\" style=\"position:relative;\"><a href=\"#warning\" aria-label=\"warning permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Warning</h2>\n<p>When using third party software whether it’s application or web app, never share secrets or your personal information.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>We saw how to take some simple steps to increase our productivity and access any content we would like across our devices. Hope you benefit from this like I did and see you next time.</p>","timeToRead":1,"frontmatter":{"title":"Access your clipboard on your other devices 😍 📋","unformattedDate":"2020-11-13T00:00:00.000Z","date":"Nov 13, 2020","path":"/copy-across-devices/","author":"Yaser Adel Mehraban","tags":["productivity","windows","showdev","clipboard"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAdABQDASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAQFAwEG/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAc2uvpOKAIP+f1LZED//xAAcEAABBAMBAAAAAAAAAAAAAAAEAAECAxAUMxH/2gAIAQEAAQUCHHjbXowWlBkFw9fAfDFZE4ttWpyrWX//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAEDAQE/AR//xAAUEQEAAAAAAAAAAAAAAAAAAAAg/9oACAECAQE/AR//xAAfEAABAgYDAAAAAAAAAAAAAAAAARICECFCgZExMnH/2gAIAQEABj8CdUuOYjM8zbC1E8LdCddH/8QAHhABAAIBBAMAAAAAAAAAAAAAAQAhERAxYZFBUXH/2gAIAQEAAT8hy9bKUzk7RVfYRJV85zxV3Zt/euJFhgaAnsMx/9oADAMBAAIAAwAAABD0/PP/xAAXEQEBAQEAAAAAAAAAAAAAAAAAIQER/9oACAEDAQE/EFd1X//EABURAQEAAAAAAAAAAAAAAAAAAAAh/9oACAECAQE/EERH/8QAIBABAAICAgEFAAAAAAAAAAAAAQARIWFB8FEQgZHB0f/aAAgBAQABPxAQZtDEV7QXB8L8lcG9OIeuL+mdjEbRZ2OvXLGKMs1fnUcLcu+YwCsy9086n//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/c581a2a2bedc6ba3797dd50c300fa2de/febd0/clipboard.jpg","srcSet":"/static/c581a2a2bedc6ba3797dd50c300fa2de/febd0/clipboard.jpg 497w","sizes":"(min-width: 497px) 497px, 100vw"},"sources":[{"srcSet":"/static/c581a2a2bedc6ba3797dd50c300fa2de/074ad/clipboard.webp 497w","type":"image/webp","sizes":"(min-width: 497px) 497px, 100vw"}]},"width":497,"height":730}}}}}},{"node":{"id":"39e34fc8-270c-55d0-b259-3b99bd690daf","html":"<p>The cat is out of the bag now, I’ve joined <a href=\"https://www.microsoft.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft</a> as an <strong>Azure Technical Trainer</strong>. Some of you might be wondering why, and if so, this post is for you. I’ve decided to write down why I’ve made this decision and a bit about my 15+ years journey from high school to where I am now.</p>\n<p>PS: We don’t have a Microsoft campus in Melbourne, but it didn’t prevent me photoshopping myself in 😜. Also, <strong>Satya Nadella</strong> was another motivation for me to join since we have a decent resemblance 😎.</p>\n<!--more-->\n<h2 id=\"background\" style=\"position:relative;\"><a href=\"#background\" aria-label=\"background permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Background</h2>\n<p>I started to write small programs when my brother bought a PC back in 1998. It was running MS-DOS and the first program I wrote could print a pyramid with stars on the console and was written in <a href=\"https://en.wikipedia.org/wiki/QBasic#:~:text=QBasic%20is%20an%20integrated%20development,on%20demand%20within%20the%20IDE.\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">QBasic</a>. From then, I was always amazed by people who write programs which can help others write their own, and working at <a href=\"https://www.microsoft.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Microsoft</a> became one of my dream jobs.</p>\n<p>Later on, I progressed through high school, pre-uni and then uni when I started my journey as a software engineer. I’ve started with <a href=\"https://en.wikipedia.org/wiki/C%2B%2B\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">C++</a>, <a href=\"https://en.wikipedia.org/wiki/Turbo_Pascal\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Turbo Pascal</a>, <a href=\"https://en.wikipedia.org/wiki/FoxPro\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">FoxPro</a>, <a href=\"https://en.wikipedia.org/wiki/Delphi_(software)\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Delphi</a>, <a href=\"https://en.wikipedia.org/wiki/Active_Server_Pages\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ASP Classic</a>, <a href=\"https://en.wikipedia.org/wiki/PHP\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">PHP</a>, and many other languages and ended up with, and finally <a href=\"https://en.wikipedia.org/wiki/ASP.NET_MVC\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ASP.Net MVC</a>.</p>\n<p>Throughout those years I became really interested to web development and have been active in that area so far. Of course that wasn’t the only thing I picked up, I have written windows desktop apps with <a href=\"https://en.wikipedia.org/wiki/ASP.NET_Web_Forms\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">ASP.Net web forms</a> and <a href=\"https://en.wikipedia.org/wiki/Spring_Framework\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Java Spring</a>, <a href=\"https://en.wikipedia.org/wiki/Java_Card\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Java Card applets</a> to work with HSM and physical security devices, ActiveX, and many more I can’t even remember, not because I didn’t like them, but because I was really into learning new things and there were too many out there.</p>\n<p>I wasn’t born in a wealthy family, so I had work summers and other free times to earn enough to go through my studies for the rest of the year. And we don’t have big companies represented in Iran, so working for Microsoft was became a wish in my bucket list.</p>\n<h2 id=\"post-uni\" style=\"position:relative;\"><a href=\"#post-uni\" aria-label=\"post uni permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Post uni</h2>\n<p>When I graduated from University with a Master’s degree in Information Security, I was hired by one of the well known software companies who were involved in banking industry. From there, I had jobs as software engineer, team lead and line manager and eventually I became the software engineering lead for one of the private banks’s PSP (payment service provider) company. But throughout all those years, I was on the lookout for an opportunity to migrate to another country and continue my professional career there.</p>\n<h2 id=\"migrating-to-australia\" style=\"position:relative;\"><a href=\"#migrating-to-australia\" aria-label=\"migrating to australia permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Migrating to Australia</h2>\n<p>We considered Canada, US, and a few countries in Europe, but ended up pinning Australia on the map because of a few different reasons which suited our lifestyle and goals. So we sold/gave away most of our household items, rented out the apartment and packed our suitcases, jumped on a plane and ended up in Melbourne, Australia in 2015. I don’t want to go through how we got the Skilled Visa because it’s simply too long and brings back many not so good memories.</p>\n<h2 id=\"first-job-here\" style=\"position:relative;\"><a href=\"#first-job-here\" aria-label=\"first job here permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>First job here</h2>\n<p>I immediately started applying for jobs here and without surprise, I was getting many calls, but not an actual opportunity that I liked. After one week, I had to bring down my expectations and start from scratch. I applied for a mid-level developer at a company and got in. This was after 3 weeks from our arrival and believe it or not is a record time for migrants to get a job.</p>\n<h2 id=\"moving-into-consulting-and-public-speaking\" style=\"position:relative;\"><a href=\"#moving-into-consulting-and-public-speaking\" aria-label=\"moving into consulting and public speaking permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Moving into consulting and public speaking</h2>\n<p>I didn’t stay there for long, as I didn’t want to waste any time following my goals. So I got into a consulting firm and eventually joined <a href=\"https://www.linkedin.com/company/readify/?originalSubdomain=au\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Readify (one of the best consulting firms in Australia)</a> back in 2016. Because of my love for knowledge sharing, I got into public speaking starting from local meetups ended up at international conferences around the world. I am super proud of what I’ve achieved throughout these years and owe a big part to Readify and later on Telstra Purple. However, I still had my bucket list getting dust and wasn’t enjoying what I was doing as my full time job.</p>\n<h2 id=\"decision-to-shift-to-developer-advocacy\" style=\"position:relative;\"><a href=\"#decision-to-shift-to-developer-advocacy\" aria-label=\"decision to shift to developer advocacy permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Decision to shift to developer advocacy</h2>\n<p>I was doing conference talks, blogs, and was involved in development community which has been a real pleasure, but managing all of that while having a full time job was really tough. So I started to search for similar roles and came across developer advocacy. However, this not a role which is very well known in Australia apart from big companies like Microsoft, Amazon AWS, IBM etc and some smaller ones like Auth0 and Twilio. I had a few discussions with different people to get an idea of what’s required to be able to score one of those jobs, but didn’t get a chance to find and apply for one.</p>\n<h2 id=\"when-an-opportunity-presents-itself\" style=\"position:relative;\"><a href=\"#when-an-opportunity-presents-itself\" aria-label=\"when an opportunity presents itself permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>When an opportunity presents itself</h2>\n<p>So I continued what I was doing, but still were on the lookout for something interesting which could help me do what I love to do. A few weeks back one of my friends who also works at Microsoft told me about a position on the Azure Technical Training team and I thought that’s something I would be really good at. It would be a bit of shift from web development, but the pros (working at <strong>Microsoft</strong>, sharing knowledge, and being close to what I love to do) convinced me to apply. I went through the interview and got an offer which made my year. This year has been really tough for me and my family and this event really helped us recover from these last few months of stress and anxiety.</p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>So here I am, employed by my dream company, and doing what I love to do. It couldn’t have ended up better than this, I’ve already talked to my manager and he knows and supports my passion to be involved in development community, so this doesn’t mean I won’t be active on conferences and blog posts anymore. This amazing opportunity will help me grow in many ways as working at Microsoft and working with so many talented and amazing people would.</p>\n<p>I just hope this has inspired a few of you fellow developers out there to never give up hope and follow your dreams however distant and impossible they seem 🤘🏽 💪🏽.</p>","timeToRead":4,"frontmatter":{"title":"I've joined Microsoft as an Azure Technical Trainer 🗺️ 😍","unformattedDate":"2020-11-02T00:00:00.000Z","date":"Nov 02, 2020","path":"/joining-microsoft/","author":"Yaser Adel Mehraban","tags":["career","dreamjob","story","journey"],"thumbnail":{"childImageSharp":{"gatsbyImageData":{"layout":"constrained","placeholder":{"fallback":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAPABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAEDBP/EABYBAQEBAAAAAAAAAAAAAAAAAAABAv/aAAwDAQACEAMQAAABJ57ZIYv/xAAcEAEAAgEFAAAAAAAAAAAAAAABAAIDERITITL/2gAIAQEAAQUC3GnucUMgTBcovb//xAAVEQEBAAAAAAAAAAAAAAAAAAAQEf/aAAgBAwEBPwGn/8QAFxEAAwEAAAAAAAAAAAAAAAAAAAERIf/aAAgBAgEBPwGO6Q//xAAaEAACAwEBAAAAAAAAAAAAAAAAAQIRITEy/9oACAEBAAY/AuGTo9s4XLEN2f/EABoQAAIDAQEAAAAAAAAAAAAAAAERACExQYH/2gAIAQEAAT8hJtT2PjBewvhvJ0ppbCqwCoQUhBl1P//aAAwDAQACAAMAAAAQdx//xAAZEQACAwEAAAAAAAAAAAAAAAAAAREhMXH/2gAIAQMBAT8QSaq6Sf/EABcRAQADAAAAAAAAAAAAAAAAAAEQEaH/2gAIAQIBAT8QbxiH/8QAGxABAQADAQEBAAAAAAAAAAAAAREAITFRYZH/2gAIAQEAAT8QRpccIIT24OzgwixBQ9+uWDpCqHf7hk2e2hzNRpBtG8yOs0aGf//Z"},"backgroundColor":"transparent","images":{"fallback":{"src":"/static/b069274e4a72185825ecd9c0b243bfac/b47b9/microsoft.jpg","srcSet":"/static/b069274e4a72185825ecd9c0b243bfac/f316d/microsoft.jpg 750w,\n/static/b069274e4a72185825ecd9c0b243bfac/30992/microsoft.jpg 1080w,\n/static/b069274e4a72185825ecd9c0b243bfac/b47b9/microsoft.jpg 1260w","sizes":"(min-width: 1260px) 1260px, 100vw"},"sources":[{"srcSet":"/static/b069274e4a72185825ecd9c0b243bfac/0aa07/microsoft.webp 750w,\n/static/b069274e4a72185825ecd9c0b243bfac/84d3c/microsoft.webp 1080w,\n/static/b069274e4a72185825ecd9c0b243bfac/a63e7/microsoft.webp 1260w","type":"image/webp","sizes":"(min-width: 1260px) 1260px, 100vw"}]},"width":1260,"height":945}}}}}},{"node":{"id":"d338d961-c38b-513d-a4b9-87e4a2548621","html":"<p>Last week I wanted to setup a <a href=\"https://v3.vuejs.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Vue.js v3</a> app with <a href=\"https://tailwindcss.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Tailwindcss</a> and although many articles exists for that, I couldn’t get it done. The fact is that you need to use <a href=\"\">postcss</a> to get your setup working, but with new version of <strong>Vue</strong>, the <code class=\"language-text\">postcss</code> config file is not picked up. So after a few try and errors, I finally got it working and thought to jot down what I went through to make it easier for my future self, and hopefully a few of my fellow developers around the world.</p>\n<!--more-->\n<h2 id=\"vue-cli\" style=\"position:relative;\"><a href=\"#vue-cli\" aria-label=\"vue cli permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Vue CLI</h2>\n<p>You can setup your <strong>Vue</strong> project with simply importing the script tag and start coding, but I normally like to use <a href=\"https://cli.vuejs.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Vue CLI</a> to get started because it takes care of the many things for me and gives a really good starting point.</p>\n<p>So let’s start by installing Vue CLI if you don’t have it already:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"6931415454203549000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`npm install -g @vue/cli\r\n# OR\r\nyarn global add @vue/cli`, `6931415454203549000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> <span class=\"token parameter variable\">-g</span> @vue/cli\r\n<span class=\"token comment\"># OR</span>\r\n<span class=\"token function\">yarn</span> global <span class=\"token function\">add</span> @vue/cli</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span></span></pre></div>\n<p>This will install the Vue CLI for you and once that’s done, you’d be ready to create your project. If you already have CLI installed, make sure you update it first to get support for <em>Vue v3 preview</em>.</p>\n<h2 id=\"creating-the-project\" style=\"position:relative;\"><a href=\"#creating-the-project\" aria-label=\"creating the project permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Creating the project</h2>\n<p>In order to create your project, you need to call the CLI and give your project name:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"1416727662775208000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`vue create vue-tailwindcss`, `1416727662775208000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">vue create vue-tailwindcss</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>This command will start the wizard and asks you what version of Vue you want to use and what additional options you want to have.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 26.296296296296294%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAFABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAL/2gAMAwEAAhADEAAAAcSYxaA//8QAFhAAAwAAAAAAAAAAAAAAAAAAARAx/9oACAEBAAEFAkJ//8QAFREBAQAAAAAAAAAAAAAAAAAAARD/2gAIAQMBAT8BZ//EABYRAQEBAAAAAAAAAAAAAAAAAAABEf/aAAgBAgEBPwGMf//EABQQAQAAAAAAAAAAAAAAAAAAABD/2gAIAQEABj8Cf//EABkQAQACAwAAAAAAAAAAAAAAAAEAEBEhUf/aAAgBAQABPyEc8gbq/9oADAMBAAIAAwAAABCH3//EABURAQEAAAAAAAAAAAAAAAAAAAEA/9oACAEDAQE/EEjDf//EABYRAQEBAAAAAAAAAAAAAAAAAAEAEf/aAAgBAgEBPxACSNv/xAAbEAEAAgIDAAAAAAAAAAAAAAABACERQVGRwf/aAAgBAQABPxB9OkED5GFjN8z/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Vue CLI wizard\"\n        title=\"\"\n        src=\"/static/f1d31a73e389807ff13ceff8a58b79b0/47311/cli-wizard.jpg\"\n        srcset=\"/static/f1d31a73e389807ff13ceff8a58b79b0/6f81f/cli-wizard.jpg 270w,\n/static/f1d31a73e389807ff13ceff8a58b79b0/09d21/cli-wizard.jpg 540w,\n/static/f1d31a73e389807ff13ceff8a58b79b0/47311/cli-wizard.jpg 1080w,\n/static/f1d31a73e389807ff13ceff8a58b79b0/bb656/cli-wizard.jpg 1297w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>You can choose between default seetings, or making a completely custom setup. I will normally choose custom which gives me more freedom as to what I want to setup.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 28.148148148148145%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAGABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBf/EABUBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHGkVNYH//EABUQAQEAAAAAAAAAAAAAAAAAAABB/9oACAEBAAEFAkf/xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/AT//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/AT//xAAUEAEAAAAAAAAAAAAAAAAAAAAQ/9oACAEBAAY/An//xAAYEAACAwAAAAAAAAAAAAAAAAABEQAQYf/aAAgBAQABPyHYS0r/2gAMAwEAAgADAAAAEIAP/8QAFhEBAQEAAAAAAAAAAAAAAAAAARAh/9oACAEDAQE/EB2f/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPxA//8QAGhAAAgIDAAAAAAAAAAAAAAAAAAERMSFRkf/aAAgBAQABPxB1JYI9lRC0+n//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Vue CLI wizard\"\n        title=\"\"\n        src=\"/static/1ca1c81a1e093f75c09a6ec363398937/47311/cli-custom.jpg\"\n        srcset=\"/static/1ca1c81a1e093f75c09a6ec363398937/6f81f/cli-custom.jpg 270w,\n/static/1ca1c81a1e093f75c09a6ec363398937/09d21/cli-custom.jpg 540w,\n/static/1ca1c81a1e093f75c09a6ec363398937/47311/cli-custom.jpg 1080w,\n/static/1ca1c81a1e093f75c09a6ec363398937/0047d/cli-custom.jpg 1620w,\n/static/1ca1c81a1e093f75c09a6ec363398937/274e1/cli-custom.jpg 2160w,\n/static/1ca1c81a1e093f75c09a6ec363398937/ab590/cli-custom.jpg 2337w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>From here press <kbd>Entre</kbd> on <strong>Choose Vue version</strong>, and select <strong>3.x (Preview)</strong>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 16.296296296296294%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAADABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAMF/8QAFQEBAQAAAAAAAAAAAAAAAAAAAAH/2gAMAwEAAhADEAAAAcSxZIH/xAAXEAEAAwAAAAAAAAAAAAAAAAAAAQIx/9oACAEBAAEFAlU7/8QAFREBAQAAAAAAAAAAAAAAAAAAEEH/2gAIAQMBAT8Bp//EABURAQEAAAAAAAAAAAAAAAAAABBB/9oACAECAQE/AYf/xAAUEAEAAAAAAAAAAAAAAAAAAAAQ/9oACAEBAAY/An//xAAXEAADAQAAAAAAAAAAAAAAAAAAATER/9oACAEBAAE/IdZaLH//2gAMAwEAAgADAAAAEIgv/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAEx/9oACAEDAQE/EIXX/8QAFhEAAwAAAAAAAAAAAAAAAAAAARAx/9oACAECAQE/EDS//8QAGhAAAQUBAAAAAAAAAAAAAAAAAQAQESExQf/aAAgBAQABPxDK0ROVzxt//9k='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Vue CLI wizard\"\n        title=\"\"\n        src=\"/static/4fd95e31fdc584eb3ee5c391f22342a4/47311/cli-vue3.jpg\"\n        srcset=\"/static/4fd95e31fdc584eb3ee5c391f22342a4/6f81f/cli-vue3.jpg 270w,\n/static/4fd95e31fdc584eb3ee5c391f22342a4/09d21/cli-vue3.jpg 540w,\n/static/4fd95e31fdc584eb3ee5c391f22342a4/47311/cli-vue3.jpg 1080w,\n/static/4fd95e31fdc584eb3ee5c391f22342a4/0047d/cli-vue3.jpg 1620w,\n/static/4fd95e31fdc584eb3ee5c391f22342a4/05ac4/cli-vue3.jpg 1753w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<p>I would normally choose <a href=\"https://www.typescriptlang.org/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">TypeScript</a>, <a href=\"https://babeljs.io/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Babel</a>, Linter, Unit and E2E testing optiuons, but feel free to setup how you like.</p>\n<p>When it’s done go navigate into the folder or open it up with your editor of choice. Mince is <a href=\"https://code.visualstudio.com/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">VS Code</a>.</p>\n<h2 id=\"installing-the-required-dependencies\" style=\"position:relative;\"><a href=\"#installing-the-required-dependencies\" aria-label=\"installing the required dependencies permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Installing the required dependencies</h2>\n<p>At this point we need to install Tailwindcss:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"89717447371337100000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`npm install tailwindcss`, `89717447371337100000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\"><span class=\"token function\">npm</span> <span class=\"token function\">install</span> tailwindcss</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<h2 id=\"create-your-style-file\" style=\"position:relative;\"><a href=\"#create-your-style-file\" aria-label=\"create your style file permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create your style file</h2>\n<p>At this stage you’re ready to create your style file. I will put it next to my <code class=\"language-text\">main.js</code> for convinience.</p>\n<p><img src=\"./main-css.jpg\" alt=\"Main style file\"></p>\n<p>Don’t forget to import it inside your main.js file:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"94849718588656290000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`import &quot;./main.css&quot;;\r\n// ...`, `94849718588656290000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\"><span class=\"token keyword\">import</span> <span class=\"token string\">\"./main.css\"</span><span class=\"token punctuation\">;</span>\r\n<span class=\"token comment\">// ...</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>And now is the time to import the <strong>Tailwincss</strong> base and components in our <code class=\"language-text\">css</code> file:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"54482061975586380000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`/* src/main.css */\r\n@import &quot;tailwindcss/base&quot;;\r\n@import &quot;tailwindcss/components&quot;;\r\n@import &quot;tailwindcss/utilities&quot;;`, `54482061975586380000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"css\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-css line-numbers\"><code class=\"language-css\"><span class=\"token comment\">/* src/main.css */</span>\r\n<span class=\"token atrule\"><span class=\"token rule\">@import</span> <span class=\"token string\">\"tailwindcss/base\"</span><span class=\"token punctuation\">;</span></span>\r\n<span class=\"token atrule\"><span class=\"token rule\">@import</span> <span class=\"token string\">\"tailwindcss/components\"</span><span class=\"token punctuation\">;</span></span>\r\n<span class=\"token atrule\"><span class=\"token rule\">@import</span> <span class=\"token string\">\"tailwindcss/utilities\"</span><span class=\"token punctuation\">;</span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"postcss-configuration\" style=\"position:relative;\"><a href=\"#postcss-configuration\" aria-label=\"postcss configuration permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Postcss configuration</h2>\n<p>Many articles tell you to create a <code class=\"language-text\">postcss.config.js</code> or <code class=\"language-text\">.postcssrc.js</code> and set your config there, but with the new version of Vue CLI this doesn’t get picked up. For this part we simply need to update our <code class=\"language-text\">package.json</code> file:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"81705995300399560000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`&quot;postcss&quot;: {\r\n  &quot;plugins&quot;: {\r\n    &quot;tailwindcss&quot;: {},\r\n    &quot;autoprefixer&quot;: {}\r\n  }\r\n}`, `81705995300399560000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"json\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-json line-numbers\"><code class=\"language-json\"><span class=\"token property\">\"postcss\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token property\">\"plugins\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token property\">\"tailwindcss\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token property\">\"autoprefixer\"</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span>\r\n  <span class=\"token punctuation\">}</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"import-tailwindcss-components\" style=\"position:relative;\"><a href=\"#import-tailwindcss-components\" aria-label=\"import tailwindcss components permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Import Tailwindcss components</h2>\n<p>You’re ready to use the Tailwindcss components now. So open up your hello-world.vue file and paste this code from <a href=\"https://tailwindui.com/preview\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">their free gallery</a> in:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"88595923437536330000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<!--\r\n  Tailwind UI components require Tailwind CSS v1.8 and the @tailwindcss/ui plugin.\r\n  Read the documentation to get started: https://tailwindui.com/documentation\r\n-->\r\n<div class=&quot;relative bg-white overflow-hidden&quot;>\r\n  <div class=&quot;max-w-screen-xl mx-auto&quot;>\r\n    <div class=&quot;relative z-10 pb-8 bg-white sm:pb-16 md:pb-20 lg:max-w-2xl lg:w-full lg:pb-28 xl:pb-32&quot;>\r\n      <svg class=&quot;hidden lg:block absolute right-0 inset-y-0 h-full w-48 text-white transform translate-x-1/2&quot; fill=&quot;currentColor&quot; viewBox=&quot;0 0 100 100&quot; preserveAspectRatio=&quot;none&quot;>\r\n        <polygon points=&quot;50,0 100,0 50,100 0,100&quot; />\r\n      </svg>\r\n\r\n      <div class=&quot;relative pt-6 px-4 sm:px-6 lg:px-8&quot;>\r\n        <nav class=&quot;relative flex items-center justify-between sm:h-10 lg:justify-start&quot;>\r\n          <div class=&quot;flex items-center flex-grow flex-shrink-0 lg:flex-grow-0&quot;>\r\n            <div class=&quot;flex items-center justify-between w-full md:w-auto&quot;>\r\n              <a href=&quot;#&quot; aria-label=&quot;Home&quot;>\r\n                <img class=&quot;h-8 w-auto sm:h-10&quot; src=&quot;https://tailwindui.com/img/logos/workflow-mark-on-white.svg&quot; alt=&quot;Logo&quot;>\r\n              </a>\r\n              <div class=&quot;-mr-2 flex items-center md:hidden&quot;>\r\n                <button type=&quot;button&quot; class=&quot;inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out&quot; id=&quot;main-menu&quot; aria-label=&quot;Main menu&quot; aria-haspopup=&quot;true&quot;>\r\n                  <svg class=&quot;h-6 w-6&quot; stroke=&quot;currentColor&quot; fill=&quot;none&quot; viewBox=&quot;0 0 24 24&quot;>\r\n                    <path stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot; d=&quot;M4 6h16M4 12h16M4 18h16&quot; />\r\n                  </svg>\r\n                </button>\r\n              </div>\r\n            </div>\r\n          </div>\r\n          <div class=&quot;hidden md:block md:ml-10 md:pr-4&quot;>\r\n            <a href=&quot;#&quot; class=&quot;font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out&quot;>Product</a>\r\n            <a href=&quot;#&quot; class=&quot;ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out&quot;>Features</a>\r\n            <a href=&quot;#&quot; class=&quot;ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out&quot;>Marketplace</a>\r\n            <a href=&quot;#&quot; class=&quot;ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out&quot;>Company</a>\r\n            <a href=&quot;#&quot; class=&quot;ml-8 font-medium text-indigo-600 hover:text-indigo-900 transition duration-150 ease-in-out&quot;>Log in</a>\r\n          </div>\r\n        </nav>\r\n      </div>\r\n\r\n      <!--\r\n        Mobile menu, show/hide based on menu open state.\r\n\r\n        Entering: &quot;duration-150 ease-out&quot;\r\n          From: &quot;opacity-0 scale-95&quot;\r\n          To: &quot;opacity-100 scale-100&quot;\r\n        Leaving: &quot;duration-100 ease-in&quot;\r\n          From: &quot;opacity-100 scale-100&quot;\r\n          To: &quot;opacity-0 scale-95&quot;\r\n      -->\r\n      <div class=&quot;absolute top-0 inset-x-0 p-2 transition transform origin-top-right md:hidden&quot;>\r\n        <div class=&quot;rounded-lg shadow-md&quot;>\r\n          <div class=&quot;rounded-lg bg-white shadow-xs overflow-hidden&quot; role=&quot;menu&quot; aria-orientation=&quot;vertical&quot; aria-labelledby=&quot;main-menu&quot;>\r\n            <div class=&quot;px-5 pt-4 flex items-center justify-between&quot;>\r\n              <div>\r\n                <img class=&quot;h-8 w-auto&quot; src=&quot;https://tailwindui.com/img/logos/workflow-mark-on-white.svg&quot; alt=&quot;&quot;>\r\n              </div>\r\n              <div class=&quot;-mr-2&quot;>\r\n                <button type=&quot;button&quot; class=&quot;inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out&quot; aria-label=&quot;Close menu&quot;>\r\n                  <svg class=&quot;h-6 w-6&quot; stroke=&quot;currentColor&quot; fill=&quot;none&quot; viewBox=&quot;0 0 24 24&quot;>\r\n                    <path stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; stroke-width=&quot;2&quot; d=&quot;M6 18L18 6M6 6l12 12&quot; />\r\n                  </svg>\r\n                </button>\r\n              </div>\r\n            </div>\r\n            <div class=&quot;px-2 pt-2 pb-3&quot;>\r\n              <a href=&quot;#&quot; class=&quot;block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out&quot; role=&quot;menuitem&quot;>Product</a>\r\n              <a href=&quot;#&quot; class=&quot;mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out&quot; role=&quot;menuitem&quot;>Features</a>\r\n              <a href=&quot;#&quot; class=&quot;mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out&quot; role=&quot;menuitem&quot;>Marketplace</a>\r\n              <a href=&quot;#&quot; class=&quot;mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out&quot; role=&quot;menuitem&quot;>Company</a>\r\n            </div>\r\n            <div>\r\n              <a href=&quot;#&quot; class=&quot;block w-full px-5 py-3 text-center font-medium text-indigo-600 bg-gray-50 hover:bg-gray-100 hover:text-indigo-700 focus:outline-none focus:bg-gray-100 focus:text-indigo-700 transition duration-150 ease-in-out&quot; role=&quot;menuitem&quot;>\r\n                Log in\r\n              </a>\r\n            </div>\r\n          </div>\r\n        </div>\r\n      </div>\r\n\r\n      <main class=&quot;mt-10 mx-auto max-w-screen-xl px-4 sm:mt-12 sm:px-6 md:mt-16 lg:mt-20 lg:px-8 xl:mt-28&quot;>\r\n        <div class=&quot;sm:text-center lg:text-left&quot;>\r\n          <h2 class=&quot;text-4xl tracking-tight leading-10 font-extrabold text-gray-900 sm:text-5xl sm:leading-none md:text-6xl&quot;>\r\n            Data to enrich your\r\n            <br class=&quot;xl:hidden&quot;>\r\n            <span class=&quot;text-indigo-600&quot;>online business</span>\r\n          </h2>\r\n          <p class=&quot;mt-3 text-base text-gray-500 sm:mt-5 sm:text-lg sm:max-w-xl sm:mx-auto md:mt-5 md:text-xl lg:mx-0&quot;>\r\n            Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.\r\n          </p>\r\n          <div class=&quot;mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start&quot;>\r\n            <div class=&quot;rounded-md shadow&quot;>\r\n              <a href=&quot;#&quot; class=&quot;w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10&quot;>\r\n                Get started\r\n              </a>\r\n            </div>\r\n            <div class=&quot;mt-3 sm:mt-0 sm:ml-3&quot;>\r\n              <a href=&quot;#&quot; class=&quot;w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-indigo-700 bg-indigo-100 hover:text-indigo-600 hover:bg-indigo-50 focus:outline-none focus:shadow-outline-indigo focus:border-indigo-300 transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10&quot;>\r\n                Live demo\r\n              </a>\r\n            </div>\r\n          </div>\r\n        </div>\r\n      </main>\r\n    </div>\r\n  </div>\r\n  <div class=&quot;lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2&quot;>\r\n    <img class=&quot;h-56 w-full object-cover sm:h-72 md:h-96 lg:w-full lg:h-full&quot; src=&quot;https://images.unsplash.com/photo-1551434678-e076c223a692?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2850&q=80&quot; alt=&quot;&quot;>\r\n  </div>\r\n</div>`, `88595923437536330000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token comment\">&lt;!--\r\n  Tailwind UI components require Tailwind CSS v1.8 and the @tailwindcss/ui plugin.\r\n  Read the documentation to get started: https://tailwindui.com/documentation\r\n--></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>relative bg-white overflow-hidden<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>max-w-screen-xl mx-auto<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>relative z-10 pb-8 bg-white sm:pb-16 md:pb-20 lg:max-w-2xl lg:w-full lg:pb-28 xl:pb-32<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>svg</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>hidden lg:block absolute right-0 inset-y-0 h-full w-48 text-white transform translate-x-1/2<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">fill</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>currentColor<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">viewBox</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>0 0 100 100<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">preserveAspectRatio</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>none<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>polygon</span> <span class=\"token attr-name\">points</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>50,0 100,0 50,100 0,100<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>svg</span><span class=\"token punctuation\">></span></span>\r\n\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>relative pt-6 px-4 sm:px-6 lg:px-8<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>nav</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>relative flex items-center justify-between sm:h-10 lg:justify-start<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>flex items-center flex-grow flex-shrink-0 lg:flex-grow-0<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>flex items-center justify-between w-full md:w-auto<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-label</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Home<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>h-8 w-auto sm:h-10<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://tailwindui.com/img/logos/workflow-mark-on-white.svg<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Logo<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>-mr-2 flex items-center md:hidden<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>button</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>button<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">id</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>main-menu<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-label</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Main menu<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-haspopup</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>true<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>svg</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>h-6 w-6<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>currentColor<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">fill</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>none<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">viewBox</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>0 0 24 24<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>path</span> <span class=\"token attr-name\">stroke-linecap</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>round<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke-linejoin</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>round<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke-width</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>2<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">d</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>M4 6h16M4 12h16M4 18h16<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n                  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>svg</span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>button</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>hidden md:block md:ml-10 md:pr-4<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Product<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Features<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Marketplace<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>ml-8 font-medium text-gray-500 hover:text-gray-900 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Company<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>ml-8 font-medium text-indigo-600 hover:text-indigo-900 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Log in<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>nav</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n\r\n      <span class=\"token comment\">&lt;!--\r\n        Mobile menu, show/hide based on menu open state.\r\n\r\n        Entering: \"duration-150 ease-out\"\r\n          From: \"opacity-0 scale-95\"\r\n          To: \"opacity-100 scale-100\"\r\n        Leaving: \"duration-100 ease-in\"\r\n          From: \"opacity-100 scale-100\"\r\n          To: \"opacity-0 scale-95\"\r\n      --></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>absolute top-0 inset-x-0 p-2 transition transform origin-top-right md:hidden<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>rounded-lg shadow-md<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>rounded-lg bg-white shadow-xs overflow-hidden<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menu<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-orientation</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>vertical<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-labelledby</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>main-menu<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>px-5 pt-4 flex items-center justify-between<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>h-8 w-auto<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://tailwindui.com/img/logos/workflow-mark-on-white.svg<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>-mr-2<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>button</span> <span class=\"token attr-name\">type</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>button<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>inline-flex items-center justify-center p-2 rounded-md text-gray-400 hover:text-gray-500 hover:bg-gray-100 focus:outline-none focus:bg-gray-100 focus:text-gray-500 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">aria-label</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>Close menu<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>svg</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>h-6 w-6<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>currentColor<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">fill</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>none<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">viewBox</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>0 0 24 24<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>path</span> <span class=\"token attr-name\">stroke-linecap</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>round<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke-linejoin</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>round<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">stroke-width</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>2<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">d</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>M6 18L18 6M6 6l12 12<span class=\"token punctuation\">\"</span></span> <span class=\"token punctuation\">/></span></span>\r\n                  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>svg</span><span class=\"token punctuation\">></span></span>\r\n                <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>button</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>px-2 pt-2 pb-3<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menuitem<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Product<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menuitem<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Features<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menuitem<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Marketplace<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-1 block px-3 py-2 rounded-md text-base font-medium text-gray-700 hover:text-gray-900 hover:bg-gray-50 focus:outline-none focus:text-gray-900 focus:bg-gray-50 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menuitem<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>Company<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>block w-full px-5 py-3 text-center font-medium text-indigo-600 bg-gray-50 hover:bg-gray-100 hover:text-indigo-700 focus:outline-none focus:bg-gray-100 focus:text-indigo-700 transition duration-150 ease-in-out<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">role</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>menuitem<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                Log in\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>main</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-10 mx-auto max-w-screen-xl px-4 sm:mt-12 sm:px-6 md:mt-16 lg:mt-20 lg:px-8 xl:mt-28<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>sm:text-center lg:text-left<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>h2</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-4xl tracking-tight leading-10 font-extrabold text-gray-900 sm:text-5xl sm:leading-none md:text-6xl<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            Data to enrich your\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>br</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>xl:hidden<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>span</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>text-indigo-600<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>online business<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>span</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>h2</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>p</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-3 text-base text-gray-500 sm:mt-5 sm:text-lg sm:max-w-xl sm:mx-auto md:mt-5 md:text-xl lg:mx-0<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>p</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-5 sm:mt-8 sm:flex sm:justify-center lg:justify-start<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>rounded-md shadow<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-500 focus:outline-none focus:border-indigo-700 focus:shadow-outline-indigo transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                Get started\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>mt-3 sm:mt-0 sm:ml-3<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>a</span> <span class=\"token attr-name\">href</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>#<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>w-full flex items-center justify-center px-8 py-3 border border-transparent text-base leading-6 font-medium rounded-md text-indigo-700 bg-indigo-100 hover:text-indigo-600 hover:bg-indigo-50 focus:outline-none focus:shadow-outline-indigo focus:border-indigo-300 transition duration-150 ease-in-out md:py-4 md:text-lg md:px-10<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n                Live demo\r\n              <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>a</span><span class=\"token punctuation\">></span></span>\r\n            <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n          <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n        <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n      <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>main</span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lg:absolute lg:inset-y-0 lg:right-0 lg:w-1/2<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n    <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>img</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>h-56 w-full object-cover sm:h-72 md:h-96 lg:w-full lg:h-full<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">src</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>https://images.unsplash.com/photo-1551434678-e076c223a692?ixlib=rb-1.2.1&amp;ixid=eyJhcHBfaWQiOjEyMDd9&amp;auto=format&amp;fit=crop&amp;w=2850&amp;q=80<span class=\"token punctuation\">\"</span></span> <span class=\"token attr-name\">alt</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span><span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n  <span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<h2 id=\"run-the-application\" style=\"position:relative;\"><a href=\"#run-the-application\" aria-label=\"run the application permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Run the application</h2>\n<p>You’re all set, run <code class=\"language-text\">npm run serve</code> and when the CLI is finished compiling the app, open a browser window and head to <code class=\"language-text\">https://localhost:8080</code> to see the <code class=\"language-text\">Tailwindcss</code> component:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 46.666666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAJABQDASIAAhEBAxEB/8QAFwAAAwEAAAAAAAAAAAAAAAAAAAQFAv/EABYBAQEBAAAAAAAAAAAAAAAAAAABAv/aAAwDAQACEAMQAAABtYZVJJNM3//EABsQAAICAwEAAAAAAAAAAAAAAAECAAMSITEz/9oACAEBAAEFAtku+Mco5l3LvT//xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAgBAwEBPwFX/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oACAECAQE/Aax//8QAGxAAAgEFAAAAAAAAAAAAAAAAAAEREBIhgaH/2gAIAQEABj8Cw+Gi5ypoxn//xAAaEAEBAAIDAAAAAAAAAAAAAAABEQAhIFFh/9oACAEBAAE/IawDTjZEej7hi0LLJwQ//9oADAMBAAIAAwAAABBE7//EABYRAQEBAAAAAAAAAAAAAAAAAAEAEf/aAAgBAwEBPxANtF//xAAWEQEBAQAAAAAAAAAAAAAAAAAAARH/2gAIAQIBAT8Qph//xAAbEAEBAAIDAQAAAAAAAAAAAAABEQAQITGBof/aAAgBAQABPxA6CZFcYqcIUS1XiZBwavTqTzXwGt//2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Tailwindcss components\"\n        title=\"\"\n        src=\"/static/4e8e031d40bfbb571c317c9f66f4233a/47311/tailwindcss-components.jpg\"\n        srcset=\"/static/4e8e031d40bfbb571c317c9f66f4233a/6f81f/tailwindcss-components.jpg 270w,\n/static/4e8e031d40bfbb571c317c9f66f4233a/09d21/tailwindcss-components.jpg 540w,\n/static/4e8e031d40bfbb571c317c9f66f4233a/47311/tailwindcss-components.jpg 1080w,\n/static/4e8e031d40bfbb571c317c9f66f4233a/0047d/tailwindcss-components.jpg 1620w,\n/static/4e8e031d40bfbb571c317c9f66f4233a/b53dc/tailwindcss-components.jpg 2038w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<h2 id=\"customisation\" style=\"position:relative;\"><a href=\"#customisation\" aria-label=\"customisation permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Customisation</h2>\n<p>If you want to customise any of the default styles, you need to modify the theme. To do so, run:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"33867387722354980000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`npx tailwind init`, `33867387722354980000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-bash line-numbers\"><code class=\"language-bash\">npx tailwind init</code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span></span></pre></div>\n<p>This will create a <code class=\"language-text\">tailwind.config.js</code> file for you in the root of your directory. To demo an example customisation, let’s say we want to add some space between the photo and the right hand side of the page. Currently the photo is having an <code class=\"language-text\">position:absolute</code> and <code class=\"language-text\">right:0</code> because it has the <code class=\"language-text\">lg:right-0</code> class.</p>\n<p>So we want to add a new class which has <code class=\"language-text\">10%</code> margin on the right hand side of the image. For that to work, we will need below code in our <code class=\"language-text\">tailwindcss.config.js</code>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"71120095365850180000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`module.exports = {\r\n  future: {\r\n    // removeDeprecatedGapUtilities: true,\r\n    // purgeLayersByDefault: true,\r\n  },\r\n  purge: [],\r\n  theme: {\r\n    inset: {\r\n      '0': 0,\r\n      auto: 'auto',\r\n      '1/10': '10%',\r\n    },\r\n    extend: {},\r\n  },\r\n  variants: {},\r\n  plugins: [],\r\n}`, `71120095365850180000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"js\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-js line-numbers\"><code class=\"language-js\">module<span class=\"token punctuation\">.</span>exports <span class=\"token operator\">=</span> <span class=\"token punctuation\">{</span>\r\n  <span class=\"token literal-property property\">future</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token comment\">// removeDeprecatedGapUtilities: true,</span>\r\n    <span class=\"token comment\">// purgeLayersByDefault: true,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">purge</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">theme</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n    <span class=\"token literal-property property\">inset</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span>\r\n      <span class=\"token string-property property\">'0'</span><span class=\"token operator\">:</span> <span class=\"token number\">0</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token literal-property property\">auto</span><span class=\"token operator\">:</span> <span class=\"token string\">'auto'</span><span class=\"token punctuation\">,</span>\r\n      <span class=\"token string-property property\">'1/10'</span><span class=\"token operator\">:</span> <span class=\"token string\">'10%'</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n    <span class=\"token literal-property property\">extend</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">variants</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">{</span><span class=\"token punctuation\">}</span><span class=\"token punctuation\">,</span>\r\n  <span class=\"token literal-property property\">plugins</span><span class=\"token operator\">:</span> <span class=\"token punctuation\">[</span><span class=\"token punctuation\">]</span><span class=\"token punctuation\">,</span>\r\n<span class=\"token punctuation\">}</span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></pre></div>\n<p>Pay attention that I’ve added a <code class=\"language-text\">1/10</code> with the value of <code class=\"language-text\">10%</code> which we can use. Now all we need to do is to add <code class=\"language-text\">lg:right-1/10</code> to the image container which pushes the image to the left by <em>10%</em>:</p>\n<div\n              class=\"gatsby-code-button-container\"\n              data-toaster-id=\"98406912166970880000\"\n              data-toaster-class=\"gatsby-code-button-toaster\"\n              data-toaster-text-class=\"gatsby-code-button-toaster-text\"\n              data-toaster-text=\"Copied to clipboard ✅\"\n              data-toaster-duration=\"3500\"\n              onClick=\"copyToClipboard(`<div class=&quot;lg:absolute lg:inset-y-0 lg:right-1/10 lg:w-1/2&quot;>\r\n</div>`, `98406912166970880000`)\"\n            >\n              <div\n                class=\"gatsby-code-button\"\n                data-tooltip=\"\"\n              >\n                Copy<svg class=\"gatsby-code-button-icon\" xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path fill=\"none\" d=\"M0 0h24v24H0V0z\"/><path d=\"M16 1H2v16h2V3h12V1zm-1 4l6 6v12H6V5h9zm-1 7h5.5L14 6.5V12z\"/></svg>\n              </div>\n            </div>\n<div class=\"gatsby-highlight\" data-language=\"html\"><pre style=\"counter-reset: linenumber NaN\" class=\"language-html line-numbers\"><code class=\"language-html\"><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;</span>div</span> <span class=\"token attr-name\">class</span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">=</span><span class=\"token punctuation\">\"</span>lg:absolute lg:inset-y-0 lg:right-1/10 lg:w-1/2<span class=\"token punctuation\">\"</span></span><span class=\"token punctuation\">></span></span>\r\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;/</span>div</span><span class=\"token punctuation\">></span></span></code><span aria-hidden=\"true\" class=\"line-numbers-rows\" style=\"white-space: normal; width: auto; left: 0;\"><span></span><span></span></span></pre></div>\n<p>And now it should look like this:</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 1080px; \"\n    >\n      <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 32.96296296296297%; position: relative; bottom: 0; left: 0; background-image: url('data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAHABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAUE/8QAFAEBAAAAAAAAAAAAAAAAAAAAAf/aAAwDAQACEAMQAAABuzwdYT//xAAaEAEAAQUAAAAAAAAAAAAAAAADAAECERIh/9oACAEBAAEFAu5ZKwbti//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAEDAQE/ASf/xAAVEQEBAAAAAAAAAAAAAAAAAAABEP/aAAgBAgEBPwFn/8QAGBAAAwEBAAAAAAAAAAAAAAAAAAERAiH/2gAIAQEABj8CI1yGWf/EABgQAQEBAQEAAAAAAAAAAAAAAAERACFB/9oACAEBAAE/IQqqzILbVR93LZTf/9oADAMBAAIAAwAAABALz//EABYRAAMAAAAAAAAAAAAAAAAAAAEQQf/aAAgBAwEBPxAKv//EABURAQEAAAAAAAAAAAAAAAAAAAEQ/9oACAECAQE/EFP/xAAbEAEAAgIDAAAAAAAAAAAAAAABESEAMUFhwf/aAAgBAQABPxDYAUVGVIEJIFkc9YJ6EMLOq8z/2Q=='); background-size: cover; display: block;\"\n  ></span>\n  <img\n        class=\"gatsby-resp-image-image\"\n        alt=\"Customise Tailwindcss\"\n        title=\"\"\n        src=\"/static/78948c2b9fef1b25d1e12a50a4324ad8/47311/tailwind-customise.jpg\"\n        srcset=\"/static/78948c2b9fef1b25d1e12a50a4324ad8/6f81f/tailwind-customise.jpg 270w,\n/static/78948c2b9fef1b25d1e12a50a4324ad8/09d21/tailwind-customise.jpg 540w,\n/static/78948c2b9fef1b25d1e12a50a4324ad8/47311/tailwind-customise.jpg 1080w,\n/static/78948c2b9fef1b25d1e12a50a4324ad8/0047d/tailwind-customise.jpg 1620w,\n/static/78948c2b9fef1b25d1e12a50a4324ad8/274e1/tailwind-customise.jpg 2160w,\n/static/78948c2b9fef1b25d1e12a50a4324ad8/375d1/tailwind-customise.jpg 3267w\"\n        sizes=\"(max-width: 1080px) 100vw, 1080px\"\n        style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n        loading=\"lazy\"\n        decoding=\"async\"\n      />\n    </span></p>\n<h2 id=\"summary\" style=\"position:relative;\"><a href=\"#summary\" aria-label=\"summary permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Summary</h2>\n<p>We saw how to add <code class=\"language-text\">Tailwindcss</code> library to our Vue 3 application created by Vue CLI. Hopefully this will help some of you out there facing the same issue as me. See you next time 👏🏽.</p>\n<p>You can find the code in my <a href=\"https://github.com/yashints/Vue-Tailwind\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">GitHub repository</a>.</p>","timeToRead":9,"frontmatter":{"title":"Get started with Vue 3 and Tailwindcss","unformattedDate":"2020-10-22T00:00:00.000Z","date":"Oct 22, 2020","path":"/vue-tailwind/","author":"Yaser Adel Mehraban","tags":["showdev","webdev","vue","tailwind"],"thumbnail":null}}}]}},"pageContext":{"limit":10,"skip":10,"numPages":13,"currentPage":2}},"staticQueryHashes":[],"slicesMap":{}}