Creating an Azure Function in existing Function App on existing Subscription and Resource Group - azure

I've developed a time triggered function in Microsoft Azure Functions with my personal subscription. The process made me create everything I needed from scratch in Visual Studio Code.
Now I would like to deploy the same function on a different subscription in which someone else have created a resource group, a function app and a storage account.
I'm not able to add these existing resources. Looks like from inside Visual Sudio Code I can only create a new resource group, storage account and function app in the same subscription as before even though I've signed out with my personal account and logged into the customer provided account.
Am I missing something obvious? Can someone point me in the right direction?

In Visual Studio Code you can select the Azure Subscription to which deploy your functions by opening the Azure tab on the left side menu (or Alt + Shift + A shortcut) and by clicking the "Select subscription" button under the "Functions" tab of that menu (see screenshot below).
screenshot

If your account has multiple subscriptions, then click this icon to select the other subscription where you need to deploy your function app or any other app as you can see in the below image:
even though I've signed out with my personal account and logged into the customer-provided account.
If the customer's subscription is available in your account, though you logged out from the account, it may have shown your subscriptions at the azure extension.
Press Ctrl + Shift + P in your VS Code, which opens the command palette.
Click on Azure: Sign Out for complete sign out in VS Code.
If you signed in again to the VS Code through Command Palette or Account extension on the sidebar, sync will not happen automatically. So, Click on Sign in to Sync settings which logs you to your Microsoft account to verify again.
Make sure this setting is turned on whichever the account (Customer's or Your Subscription) you logged in to VS Code.
This setting helps you to deploy your applications with any subscription in your account through the VS Code Editor.

Although other responses were useful to me and might prove useful to others, my specific problem was caused by the "Azure: Tenant" setting in the Visual Studio Code Settings.
This setting basically sets a specific subscription to use (identified by its ID). Once removed, with this field empty, the default behavior of the extension is to ask each time where to deploy a function.
As soon as I removed the value for this setting the second subscription appeared in Azure extension panel.

Related

How do I sign in to my Azure account from the VSCode Azure Functions extension?

I have been trying to create an Azure Function using the documentation. For example, here:
https://learn.microsoft.com/en-us/learn/modules/develop-azure-functions/5-create-function-visual-studio-code
Every time, and with every Azure account, I can't get past the step where you sign in to your Azure account from the Azure Functions VSCode extension. This is the error I am getting:
"Selected user account does not exist in tenant 'Microsoft Learn Sandbox' and cannot access the application 'aebc6443-996d-45c2-90f0-388ff96faa56' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account."
The Microsoft Learn Sandbox error message is a red herring to me, as I am not trying to do anything with it, only with Azure Functions. The same error appears even with a completely different Azure account.
I have tried looking at several possible solutions, including switching directories (but I only have one directory, so this didn't work), changing settings in Azure AD Connect (but I don't have Azure AD Connect configured, so this didn't work), and I deleted several local .config files and directories on my machine (CentOS 7, btw). If the solution is related to my .config files, I couldn't tell which files I should actually be deleting though.
In my situation, the problem is it was trying to use my "learning" account but I wanted to use my "work" account.
Following the answer here: https://learn.microsoft.com/en-us/answers/questions/696758/how-do-i-sign-in-to-azure-from-vs-code?page=1&orderby=Helpful&comment=answer-697695#newest-answer-comment
Go to the Azure portal and sign out (https://portal.azure.com/) Now
open Visual Studio and Open the Command Palette (Ctrl + Shift + P)
search for Azure: Sign Out and click on it. It will signout you from the Visual Studio extension
Then (this is the important part) it allowed me the option to Clear my Tenant ID.
Then you can sign in again with the new account
Hope this helps someone else!

From Visual Studio, unable to publish to Azure App Service

Using this Official Azure tutorial. I have work Azure account that I can successfully login. The account allows $150 per month of which I have $93 left.
But, as instructed in Publish to Azure App Service section of the tutorial, when I select Azure App Service as the Publish Target on the wizard, it takes me to following screen where I sign in as my work Azure account. But it does nothing after I login, and the Next button stayed grey. When I click on can't access account button and fill in requested info, I get the next screen (also shown in the image below). I, then first successfully logged in to my Azure account from outside of VS2017 and then tried the above process again but still the same issue:
UPDATE
Moreover, I just deployed the same app using this Official Azure tutorial that is not using Visual Studio. But I want to able to deploy it using VS2017 as I create projects using VS2017 only.
I think your problem is the identity (MS acct) which you are logged into VS2017 with. You want to be sure that you are logged in to VS with the account which has rights to the subscription where you are trying to publish. Assuming that's your org account:
Click on your profile in the upper right corner and choose Account Settings. The window that pops up has a link to Add an account. You'll want to add your org account here. Now VS has the proper creds to publish to your subscription.
To verify that the creds are working, use the menu item View -> Cloud Explorer. You should see the other assets you've created in the target subscription.

How to publish a Web Application to another persons azure subscription

I currently have a Web Application and SQL Database instance published on my own personal Azure trial subscription. However the app is now finished and I want to hand ownership over to the person I am creating it for. So I want to publish it to his Azure subscription, so he can look after billing, monitor, and have ownership of the application etc.
I asked him to add me as a user to his account, and now I see his company name listed as a 'Directory' from the portals home page (along with my Default Directory, my Web App, and my SQL Database). I don't know how to proceed from here. I want to be able to Publish it from Visual Studio 2013 - then run my code first migrations to create the database, all to a location that his company and not me is responsible for.
Is my approach to this wrong? In a general sense, how do you develop a test application (and test it in Azure) and publish it for someone else on Azure?
The first comment on the question is sort of what I am trying to achieve:
Transfer all data from my account to another in the same Azure subscription
"What do you mean by from my account to another in the same Azure subscription? Normally I have seen folks want to move data from one subscription to another one (say from Dev Subscription to Prod Subscription)."
But if I just transfer the app I wouldn't be able to make changes in VS and re-publish it, for example.
EDIT:
I found this article on Migrating an enterprise web app to an Azure service. Would it be possible to Publish the app to my local dev machine (with local database), then use the Migration Assistance to move it to Azure? Obviously to do this I would need my clients Microsoft ID and password to log into his subscription which is not ideal.
You will first want to make sure that the subscription appears in your "Subscription list" in the top right corner and is selected.
I am assuming you have connected your VS with your Azure subscription and are able to publish your app to your subscription from here, and that the new subscription is "missing" from your selection. But now you have been added to a new subscription but have not updated VS. Remove and readd Azure Subscriptions from VS. This should require you to log into Azure, and should pull updated account information.
Now when you Deploy your app, you will be able to select which Subscription you want to deploy it into.

Windows Azure Publish Website- "Unable to get subscription information. An item with the same key has already been added"

I'm following this tutorial here
http://www.windowsazure.com/en-us/develop/net/tutorials/get-started/#nextsteps
I'm at step 3. I click import, I can see I'm signed in with my MSDN ultimate account (I get $150 per month to spend on Azure). I then click New, and when the dialogue opens I cannot enter anything (all boxes are disabled), along with an error message in red:
http://gyazo.com/17eb15f07d54e2867cd5f21d377f04aa
Why is this? It is something with my MSDN account?
You can get also this problem if your MS account is registered with more than one Azure subscription. It appears Visual studio gets confused if your account is attached to more than one subscription and tries to use the wrong one for accessing the Azure API.
If it occurs you need to ignore the advice from #Dev Trails and instead do the following:
In Server Explorer, right-click Windows Azure node > Manage Subscriptions
In the Certificates tab Import a new subscription certificate (this will take you to the current link on the Azure portal to download your
certificate)
In the Subscriptions tab, on the specific subscription that fails,
select the drop-down and choose the certificate instead of the
username.
Refreshing the Azure explorer should now show your databases etc without error.
This is a bug in Visual Studio 2013. Found an answer posted here:
To workaround the issue, you can try the following:
In Server Explorer, right-click Windows Azure node > Manage Subscriptions
If you are signed-in to Azure, you will see the same subscription show up both in the Accounts tab and in the Certificates tab. Remove the one in the Certificates tab.
VS 2015: delete all MS Account from VS. Add once again.

Change Azure Website Subscription

I had a free trial with windows azure, I was out of the country and it ran out.
I have now upgraded to a pay-as-you-go account. All good.
However, my previous websites still run off my old subscription, is there any way to reactivate these websites using my new pay-as-you-go subscription?
If you upgraded the existing free account versus opened a new pay-as-you-go account, this should have been a seamless transition.
You can contact support - use the Billing Questions option and then select Transfer Subscription, and they should be able to help you.
Alternatively, of course, you could redeploy your assets to the new subscription.
I created a "Billing" ticket with microsoft. There is a type of ticket as you go through their wizard specifically for this. They were able to upgrade my "Free Trial" to the pay as you go AFTER i had let the free trial expire. The downside was that all my virtual machines were deleted. It did however give me access to my websites and storage without any problem. I was able to recreate all the VM's using the storage vhd's.
My experience on this is that I just redeploy to a new website I created under new subscription. I didn't find a way to move them over to new subscription.
You can move SQL Azure to new subscription, but not website. To move SQL Azure to new subscription, you will need to use old Azure portal management. Follow this step:
http://blogs.msdn.com/b/windowsazure/archive/2012/03/07/moving-sql-azure-servers-between-subscriptions.aspx
Note that you are moving the server where the database lives. So, if you have more than one DB in the same server, everything will be moved.
You can move Azure SQL DB from one subscription to another on https://manage.windowsazure.com
Both subscriptions should in the same Default Directory. If they are in different directories then select:
Subscriptions
Manage subscriptions/directory
Select subscription and click "Edit" at the bottom.
Choose directory where other subscription and click "Next".
When both subscriptions in the same directory.
Choose "SQL Databases"
Select proper server
and in Quick Glance you should see "Change subscription"
The documentation in the link stack247 posted is now outdated. To change the target subscription for a database, you have to change the target subscription of the server for the database. There are several ways to navigate to the server, but here is just one example:
Click on the database tab
Click on the name of the database you want to change
In the dashboard view, click on the link to the server in the quick glance section. This is on the bottom right corner of the view.
In the dashboard view, click on the Change Subscription link in the quick glance section. This is on the right side of the view.
Change the Target Subscription, and click the check button.
As far as changing the subscription for a website or cloud service, I would do what is recommended above; and republish the website or cloud service. When you publish, change the settings to target a different subscription by clicking on the previous button.
---------Update----------
If you have a bunch of assets that need to be moved to another account, create a ticket with the Azure helpdesk. You will have to do the above and switch out the accounts for the databases/servers, but Microsoft is able to run a script on their end that moves everything. Depending on the size of your assets, it may take a little longer. Fortunately for me, it was only a day to move everything. I would recommend doing this instead of publishing everything a second time.
https://manage.windowsazure.com/?getsupport=true
All the solutions mentioned above are now outdated.
In the https://portal.azure.com/,
For SQL Servers, go in the "SQL Servers" menu, select the server to change. In the Overview, click on the Edit button, located right to the name of the subscription.
For WebApps, go to the "App Service plans" menu, select your plan, click on the Resource Group and in the Overview, click on the Edit button, located right to the name of the subscription.

Resources