Getting the name and location of the deployment the webrole belongs to - azure

I want to be able to get the name (named when the hosted service was created) and the location (North Europe, Asia Anywere, etc) of the deployment from within a running web role. I don't want to rely on a certificate and the subscription ID.
Something like:
// Current role name. Ex: WebRole_IN_0
RoleEnvironment.CurrentRoleInstance.Id
// Deployment id of the role. Ex: 44b522f7e8b94412b046bbab08116d87
RoleEnvironment.DeploymentId
but just returning the deployment name and deployment location.
Is this possible without going through the REST api using the subscription ID and a certificate file?

No, this can't be done without using the Service Management API. Why not just put it in configuration settings? It can't change after deployment...

Related

App service name in Azure DevOps shows No Results Found

I selected the Azure Subscription that matches the Subscription ID from my app service in Azure Portal, but I keep getting this message No Results Found when I try to select an App Service Name.
Please check if you Service connection is not limited to resource group. For instace this one is:
To check this please go to: Project Settings -> Service Connections -> end edit connection to see details.
Resource group should be empty if your choice is to do not limit connection to particular resource group.
So my guess is that your connection is limited to resource group which doesnt have app service.
I would suggest you to please check the App type i.e., webapp you created on window, or some other OS based on select the App type. I created my web app on Windows OS and can be able to see the app service name populating over here.
Search for the Task : AZURE APP SERVICE DEPLOY

ARM Template, server name already exists but actually it didn't

I'm trying to create a SQL Server using ARM Template.
While executing it, its throws an error of:
Server Name already exists
but it does not.
I tried deploying it in many subscriptions and resource group of different regions but outcome is always same.
I'm calling resource group name as SQL Server name using [resourceGroup().name].
Also, along with SQL Server, Vnet,Nsg,Local Network Gateway, VPN Gateway is deployed using resource group but are created successfully.
The SQL Server name must be unique for all of Azure, not only within your subscription.
You get a fully qualified domain name for it, so you need a unique name:
yourservername.database.windows.net
Azure SQL server name should be universal unique not for your subscription

How to know the origin resource group of a App Service Plan?

I have an Azure App Service Plan and a Web App. I want to move them to another subscription. There is a limitation that app service plan and app service must be moved together from the origin resource group of the app service plan. Someone had moved the resources from their origin resource group and deleted the resource group. Now, how can I find the name of the origin resource group ?
In some cases it can be found in the WebSpace property of app service plan. For example [ "webSpace": "RG-SK-MarkIII-CentralUSwebspace" ], RG-SK-MarkIII is the origin resource group of the app plan. But in my case the webSpace is like this ["webSpace": "AustraliaEastwebspace" ]. Is there any other way to find it through CloudShell ?
You can look up the actions taken by a particular user, even for a resource group that no longer exists.
az monitor activity-log list -g ExampleGroup --caller someone#contoso.com --offset 5d
Kindly try these steps:
If you don't remember the original resource group, you can find it through diagnostics.
For your web app, select Diagnose and solve problems.
Then, select Configuration and Management.
Select Migration Options.
Select the option for recommended steps to move the web app.
You see the recommended actions to take before moving the resources. The information includes the original resource group for the web app.
- I understand you're referring to RG deletion scenario, kindly try this and let me know how it goes.
Reference document move across subscription.
Furthermore, you can only change to a plan that was created in the same "webspace" as your original app. Webspace is an internal concept that's not exposed, but you can verify whether your source and destination plans are in the same webspace or not.
To verify, do the following:
https://resources.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/serverfarms/{serverFarmName}
Confirm whether the webSpace property of your source plan matches the webSpace property of your new plan

Deploy a resource group with App Service

I have published an API app from Visual Studio to a new resource group, also created an App Service Plan, so after the deployment the resource group contains 2 items:
AppServicePlan1
AppService1
Now I am trying to deploy these items to another resource group as follows:
Select 'Automation script' in the resource group settings
Click 'Deploy'
Select 'Create new' resource group, enter its name
Enter 'Serverfarms_AppServicePlan1_name' parameter value (new app service plan name, e.g. AppServicePlan2)
Enter 'Sites_AppService1_name' parameter value (new app service name, e.g. AppService2)
Tick 'Agree to terms and conditions'
Click 'Puchase'
The process fails with the following error message:
"The host name AppService1.azurewebsites.net is already assigned to another Azure website: AppService1."
I have tried different things - deploying app service plan, logic apps, etc. from one resource group to another works fine, but deploying an app service fails as described above.
I have tried changing the hostNames property in the template file to ["AppService2.azurewebsites.net"] manually - I'm not getting the error then (although I'm not sure, maybe something else also needs to be changed, e.g. properties enabledHostNames, hostNameSslStates?) and the deployment seems to work, however the 'deployed' app service can't be used as it contains only 1 file - hostingstart.html.
What am I missing?
I think you have everything correct - as you noticed when you use the generated automation script it will create everything with the same properties that currently exist. We try to parameterize the correct value (like the web app name) but there are some details that can be overlooked (like host names). After changing all that it sounds like you got it to deploy.
The "code" however is not part of the automation script - only the infrastructure and configuration. So you still need to deploy your app to have it be identical. You can folder app deployment into the JSON template (using webdeploy or github) but since that requires access to external artifacts, that's not done automatically.
That help?

How to get subscription id programmatically in a Azure Role?

I have this Worker Role which makes use of REST Management API (through https://github.com/Azure/azure-sdk-for-net), whose the most basic pre-requisite is the Subscription ID.
Is there a way to get the Subscription ID from a running (worker) role? E.g. say, through RoleEnvironment?
Sorry Gatis, there is no way to get this via any method provided by Azure*. You would need to pass this information into your role using something like the CSCFG configuration settings.
For a little more context - the subscription ID is only known at the RDFE layer. Once you are in the Fabric layer (ie. your running Worker Role) then there is no concept of a subscription ID. You can see http://blogs.msdn.com/b/kwill/archive/2011/05/05/windows-azure-role-architecture.aspx, process A and steps 1&2, for a little more info.
*If you are using AAD authentication for your Service Management API calls then you could get a list of all subscriptions for that AAD user using 'List Azure Subscriptions' - http://msdn.microsoft.com/en-us/library/azure/dn775050.aspx. With those subscriptions you could enumerate all cloud services and match the deployment ID to the deployment ID for your worker role.
Edit: Typo in first paragraph. Changed 'something like the Subscription ID' to 'something like the CSCFG configuration settings'.

Resources