Get the “PRIMARY STATIC WEBSITE ENDPOINT” from Azure PowerShell












0















In the Azure Portal I can look up a Storage Account and go to the Settings/Properties section and see the list of properties which contains PRIMARY STATIC WEBSITE ENDPOINT. Alternatively I can see the same information in the Settings/Static Website section marked as Primary endpoint



How do I get that with the Azure PowerShell "Az" module?



Alternatively, I can piece together the URL if I can find the zone information from somewhere. e.g. From this template https://<ACCOUNT_NAME>.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>



Or is there another way I can get the information I need easily from within a PowerShell script?










share|improve this question



























    0















    In the Azure Portal I can look up a Storage Account and go to the Settings/Properties section and see the list of properties which contains PRIMARY STATIC WEBSITE ENDPOINT. Alternatively I can see the same information in the Settings/Static Website section marked as Primary endpoint



    How do I get that with the Azure PowerShell "Az" module?



    Alternatively, I can piece together the URL if I can find the zone information from somewhere. e.g. From this template https://<ACCOUNT_NAME>.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>



    Or is there another way I can get the information I need easily from within a PowerShell script?










    share|improve this question

























      0












      0








      0








      In the Azure Portal I can look up a Storage Account and go to the Settings/Properties section and see the list of properties which contains PRIMARY STATIC WEBSITE ENDPOINT. Alternatively I can see the same information in the Settings/Static Website section marked as Primary endpoint



      How do I get that with the Azure PowerShell "Az" module?



      Alternatively, I can piece together the URL if I can find the zone information from somewhere. e.g. From this template https://<ACCOUNT_NAME>.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>



      Or is there another way I can get the information I need easily from within a PowerShell script?










      share|improve this question














      In the Azure Portal I can look up a Storage Account and go to the Settings/Properties section and see the list of properties which contains PRIMARY STATIC WEBSITE ENDPOINT. Alternatively I can see the same information in the Settings/Static Website section marked as Primary endpoint



      How do I get that with the Azure PowerShell "Az" module?



      Alternatively, I can piece together the URL if I can find the zone information from somewhere. e.g. From this template https://<ACCOUNT_NAME>.<ZONE_NAME>.web.core.windows.net/<FILE_NAME>



      Or is there another way I can get the information I need easily from within a PowerShell script?







      azure azure-powershell






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 20 at 14:08









      Colin MackayColin Mackay

      14.5k34973




      14.5k34973
























          2 Answers
          2






          active

          oldest

          votes


















          3














          You can get the PRIMARY STATIC WEBSITE ENDPOINT details using Az module with the below command or snippet.



          (Get-AzStorageAccount -ResourceGroupName <RESOURCEGROUPNAME> -Name <STORAGEACCOUNTNAME>|select PrimaryEndpoints).PrimaryEndpoints.Web


          For illustration, please see below screenshot.
          enter image description here



          Hope this helps!! Cheers!!






          share|improve this answer
























          • Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

            – Colin Mackay
            Jan 21 at 17:15



















          1














          I've found a sort of solution. It doesn't feel ideal. I would hope that there is a more concise and less fragile way to get this information but the following gets me what I am looking for in PowerShell, after a fashion.



          I had to install an additional PowerShell module, that I would have thought be installed already, but...



          Install-Module Az.ResourceGraph


          And then I was able to use the Search-AzGraph function like this:



          (Search-AzGraph -Subscription <SubscriptionGuidHere> `
          -Query "where type == 'microsoft.storage/storage
          accounts' | where name == '<StorageAccountName>' | limit 1")`
          .aliases `
          .'Microsoft.Storage/storageAccounts/primaryEndpoints.web'


          I don't know if this is the best query syntax, as I managed to cobble it together from a variety of documentation I've only just found and a bit of brute force and ignorance.



          The above is also a little fragile - I suspect there is caching going on somewhere, or maybe where this function gets its information from simply hasn't got the latest information. If you run this too quickly after creating the storage account you get nothing back, but wait a few seconds and it returns the information. The longest I've had to wait for the above to bring back results is about 30 seconds.



          If anyone has a better solution, I'd love to go down that route instead, as Search-AzGraph is probably okay for monitoring, but not good when you want to get the name of an end point so the next part of a script can use that to continue what it is doing.






          share|improve this answer


























          • From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

            – Thomas
            Jan 20 at 21:37











          • Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

            – Thomas
            Jan 20 at 21:39











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277273%2fget-the-primary-static-website-endpoint-from-azure-powershell%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          You can get the PRIMARY STATIC WEBSITE ENDPOINT details using Az module with the below command or snippet.



          (Get-AzStorageAccount -ResourceGroupName <RESOURCEGROUPNAME> -Name <STORAGEACCOUNTNAME>|select PrimaryEndpoints).PrimaryEndpoints.Web


          For illustration, please see below screenshot.
          enter image description here



          Hope this helps!! Cheers!!






          share|improve this answer
























          • Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

            – Colin Mackay
            Jan 21 at 17:15
















          3














          You can get the PRIMARY STATIC WEBSITE ENDPOINT details using Az module with the below command or snippet.



          (Get-AzStorageAccount -ResourceGroupName <RESOURCEGROUPNAME> -Name <STORAGEACCOUNTNAME>|select PrimaryEndpoints).PrimaryEndpoints.Web


          For illustration, please see below screenshot.
          enter image description here



          Hope this helps!! Cheers!!






          share|improve this answer
























          • Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

            – Colin Mackay
            Jan 21 at 17:15














          3












          3








          3







          You can get the PRIMARY STATIC WEBSITE ENDPOINT details using Az module with the below command or snippet.



          (Get-AzStorageAccount -ResourceGroupName <RESOURCEGROUPNAME> -Name <STORAGEACCOUNTNAME>|select PrimaryEndpoints).PrimaryEndpoints.Web


          For illustration, please see below screenshot.
          enter image description here



          Hope this helps!! Cheers!!






          share|improve this answer













          You can get the PRIMARY STATIC WEBSITE ENDPOINT details using Az module with the below command or snippet.



          (Get-AzStorageAccount -ResourceGroupName <RESOURCEGROUPNAME> -Name <STORAGEACCOUNTNAME>|select PrimaryEndpoints).PrimaryEndpoints.Web


          For illustration, please see below screenshot.
          enter image description here



          Hope this helps!! Cheers!!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 21 at 7:17









          KrishnaG-MSFTKrishnaG-MSFT

          1713




          1713













          • Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

            – Colin Mackay
            Jan 21 at 17:15



















          • Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

            – Colin Mackay
            Jan 21 at 17:15

















          Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

          – Colin Mackay
          Jan 21 at 17:15





          Thank you, that's absolutely fantastic - I don't even have to repeatedly call it as it always gives me the result.

          – Colin Mackay
          Jan 21 at 17:15













          1














          I've found a sort of solution. It doesn't feel ideal. I would hope that there is a more concise and less fragile way to get this information but the following gets me what I am looking for in PowerShell, after a fashion.



          I had to install an additional PowerShell module, that I would have thought be installed already, but...



          Install-Module Az.ResourceGraph


          And then I was able to use the Search-AzGraph function like this:



          (Search-AzGraph -Subscription <SubscriptionGuidHere> `
          -Query "where type == 'microsoft.storage/storage
          accounts' | where name == '<StorageAccountName>' | limit 1")`
          .aliases `
          .'Microsoft.Storage/storageAccounts/primaryEndpoints.web'


          I don't know if this is the best query syntax, as I managed to cobble it together from a variety of documentation I've only just found and a bit of brute force and ignorance.



          The above is also a little fragile - I suspect there is caching going on somewhere, or maybe where this function gets its information from simply hasn't got the latest information. If you run this too quickly after creating the storage account you get nothing back, but wait a few seconds and it returns the information. The longest I've had to wait for the above to bring back results is about 30 seconds.



          If anyone has a better solution, I'd love to go down that route instead, as Search-AzGraph is probably okay for monitoring, but not good when you want to get the name of an end point so the next part of a script can use that to continue what it is doing.






          share|improve this answer


























          • From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

            – Thomas
            Jan 20 at 21:37











          • Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

            – Thomas
            Jan 20 at 21:39
















          1














          I've found a sort of solution. It doesn't feel ideal. I would hope that there is a more concise and less fragile way to get this information but the following gets me what I am looking for in PowerShell, after a fashion.



          I had to install an additional PowerShell module, that I would have thought be installed already, but...



          Install-Module Az.ResourceGraph


          And then I was able to use the Search-AzGraph function like this:



          (Search-AzGraph -Subscription <SubscriptionGuidHere> `
          -Query "where type == 'microsoft.storage/storage
          accounts' | where name == '<StorageAccountName>' | limit 1")`
          .aliases `
          .'Microsoft.Storage/storageAccounts/primaryEndpoints.web'


          I don't know if this is the best query syntax, as I managed to cobble it together from a variety of documentation I've only just found and a bit of brute force and ignorance.



          The above is also a little fragile - I suspect there is caching going on somewhere, or maybe where this function gets its information from simply hasn't got the latest information. If you run this too quickly after creating the storage account you get nothing back, but wait a few seconds and it returns the information. The longest I've had to wait for the above to bring back results is about 30 seconds.



          If anyone has a better solution, I'd love to go down that route instead, as Search-AzGraph is probably okay for monitoring, but not good when you want to get the name of an end point so the next part of a script can use that to continue what it is doing.






          share|improve this answer


























          • From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

            – Thomas
            Jan 20 at 21:37











          • Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

            – Thomas
            Jan 20 at 21:39














          1












          1








          1







          I've found a sort of solution. It doesn't feel ideal. I would hope that there is a more concise and less fragile way to get this information but the following gets me what I am looking for in PowerShell, after a fashion.



          I had to install an additional PowerShell module, that I would have thought be installed already, but...



          Install-Module Az.ResourceGraph


          And then I was able to use the Search-AzGraph function like this:



          (Search-AzGraph -Subscription <SubscriptionGuidHere> `
          -Query "where type == 'microsoft.storage/storage
          accounts' | where name == '<StorageAccountName>' | limit 1")`
          .aliases `
          .'Microsoft.Storage/storageAccounts/primaryEndpoints.web'


          I don't know if this is the best query syntax, as I managed to cobble it together from a variety of documentation I've only just found and a bit of brute force and ignorance.



          The above is also a little fragile - I suspect there is caching going on somewhere, or maybe where this function gets its information from simply hasn't got the latest information. If you run this too quickly after creating the storage account you get nothing back, but wait a few seconds and it returns the information. The longest I've had to wait for the above to bring back results is about 30 seconds.



          If anyone has a better solution, I'd love to go down that route instead, as Search-AzGraph is probably okay for monitoring, but not good when you want to get the name of an end point so the next part of a script can use that to continue what it is doing.






          share|improve this answer















          I've found a sort of solution. It doesn't feel ideal. I would hope that there is a more concise and less fragile way to get this information but the following gets me what I am looking for in PowerShell, after a fashion.



          I had to install an additional PowerShell module, that I would have thought be installed already, but...



          Install-Module Az.ResourceGraph


          And then I was able to use the Search-AzGraph function like this:



          (Search-AzGraph -Subscription <SubscriptionGuidHere> `
          -Query "where type == 'microsoft.storage/storage
          accounts' | where name == '<StorageAccountName>' | limit 1")`
          .aliases `
          .'Microsoft.Storage/storageAccounts/primaryEndpoints.web'


          I don't know if this is the best query syntax, as I managed to cobble it together from a variety of documentation I've only just found and a bit of brute force and ignorance.



          The above is also a little fragile - I suspect there is caching going on somewhere, or maybe where this function gets its information from simply hasn't got the latest information. If you run this too quickly after creating the storage account you get nothing back, but wait a few seconds and it returns the information. The longest I've had to wait for the above to bring back results is about 30 seconds.



          If anyone has a better solution, I'd love to go down that route instead, as Search-AzGraph is probably okay for monitoring, but not good when you want to get the name of an end point so the next part of a script can use that to continue what it is doing.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 20 at 21:14

























          answered Jan 20 at 15:01









          Colin MackayColin Mackay

          14.5k34973




          14.5k34973













          • From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

            – Thomas
            Jan 20 at 21:37











          • Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

            – Thomas
            Jan 20 at 21:39



















          • From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

            – Thomas
            Jan 20 at 21:37











          • Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

            – Thomas
            Jan 20 at 21:39

















          From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

          – Thomas
          Jan 20 at 21:37





          From the documentation you can query the endpoint url using az cli: az storage account show -n <ACCOUNT_NAME> -g <RESOURCE_GROUP> --query "primaryEndpoints.web" --output tsv

          – Thomas
          Jan 20 at 21:37













          Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

          – Thomas
          Jan 20 at 21:39





          Not sure how the new Az powershell modules works, it supposed to work like the az cli but never tried

          – Thomas
          Jan 20 at 21:39


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54277273%2fget-the-primary-static-website-endpoint-from-azure-powershell%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Homophylophilia

          Updating UILabel text programmatically using a function

          Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage