Reputation: 33
I have restricted access to a client Azure Resources. The client created a default static-webapp (let's call it "my-mvp"
) and a virtual machine for me to deploy a app and a api. I am not allowed to create any new static-webapps or any other service. When using the swa deploy
-command it does not allow me to connect the existing source.
How can I link my-mvp
project to the existing my-mvp static webapp in Azure?
Deployment on my own Azure subscription works just fine when using the swa deploy
command and creating a new Static WebApp. Also my .yml
configuration works fine so I got it all working. This question has merly to do with the usage of the swa-cli
.
While trying out the swa-cli with swa deploy
-command with the following configuration (swa-cli.config.json);
{
"$schema": "https://aka.ms/azure/static-web-apps-cli/schema",
"configurations": {
"my-mvp": {
"appName": "my-mvp",
"appLocation": "./apps/frontend",
"outputLocation": "build",
"appBuildCommand": "npm run build",
"run": "npm start",
"appDevserverUrl": "http://localhost:3000",
"apiLocation": "./apps/backend",
"apiBuildCommand": "npm run build",
"apiRunCommand": "npm run start:dev",
"apiDevserverUrl": "http://localhost:3002",
"apiPort": 3002,
"appPort": 3000,
"subscriptionId": "omitted for obvious reasons",
"resourceGroupName": "omitted for obvious reasons",
"tenantId": "omitted for obvious reasons"
}
}
}
I got the following output;
Checking project "my-mvp" settings...
✖ The project "my-mvp" is linked to "DevOps"!
✖ Unlink the project from the "DevOps" provider and try again.
my-mvp
is the name of the static-webapp resource in Azure DevOps were I'm trying to attach this project to.
If I rename the appName
to something else it gives me the default options;
Checking project "my-other-mvp" settings...
? Would you like to create a new Azure Static Web Apps project? › (Y/n)
Because I'm not allowed to create any new Static Web App I press "n";
Checking project "my-other-mvp" settings...
✔ Would you like to create a new Azure Static Web Apps project? … no
✖ The provided project name "my-other-mvp" was not found.
If I press "Yes" the response is a RestError. If I enter "Yes" with the appName "my-mvp" it gives me the very first reponse.
Is it possible to use the swa-cli
with existing resources?
Upvotes: 0
Views: 975
Reputation: 1
You have to disconnect the existing app first!
First, install the Azure CLI: https://learn.microsoft.com/pt-br/cli/azure/install-azure-cli
After that, run the following command in your Terminal to login:
$ az login
If you use resource groups, set your default resource group with this command:
$ az configure --defaults group=YOUR-RESOURCE-GROUP
Finally, disconnect the web app with the following command
$ az staticwebapp disconnect -n APP-NAME
For you, it should be:
$ az staticwebapp disconnect -n my-mvp
Upvotes: 0