Get the “PRIMARY STATIC WEBSITE ENDPOINT” from Azure PowerShell
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
add a comment |
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
add a comment |
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
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
azure azure-powershell
asked Jan 20 at 14:08
Colin MackayColin Mackay
14.5k34973
14.5k34973
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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.
Hope this helps!! Cheers!!
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
add a comment |
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.
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Hope this helps!! Cheers!!
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
add a comment |
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.
Hope this helps!! Cheers!!
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
add a comment |
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.
Hope this helps!! Cheers!!
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.
Hope this helps!! Cheers!!
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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